How did that happen?
I guess I kept learning more and more about it. I had no choice. When you get a task that deals with the database and SQL, you just have to dive in, find a way and solve your issue.
So I did just that: I solved my issue. Then I got a new task, and moved on.
Until I randomly came across an article, explaining the process and mechanisms involved when a SQL command is executed.
And it blew my mind.
What I learned:
Journey of a SQL Statement:
The execution of a SQL statement involves several stages:SQL Parser: Breaks down and verifies the SQL query.
Query Optimizer: Determines the most efficient way to execute the query.
Execution Engine: Carries out the query according to the plan.
Storage Engine: Manages data storage and retrieval. For example, in MySQL, this could be the InnoDB or MyISAM engines.
Optimization and Performance:
By understanding these components, we can:Enhance query performance through a better understanding of data indexing and storage.
Choose effective indexing strategies.
Manage resources more efficiently (e.g., memory, caching, execution parallelism).
Diagnose and mitigate performance bottlenecks.
Wait….does that sound familiar? Parser, optimizing, storage….
We’re just in another system, this is a piece of software! Like the ones I work on.
I know, I know, this may seem obvious to some people, but it just never occurred to me. In my mind SQL was that black box of who-knows-what-happens-in-there.
Anyway…
Not scared anymore!
I even got some practice in and put together a nice materialized view (remember that task I had to work on? It took me 2 days to pin down the correct query, but that’s another story).
I still need to practice the optimization and performance piece, but now it’s on my radar.
Thank you for reading!
Adeline.
The rabbit hole:
https://www.thecodingdev.com/2024/05/what-happens-when-sql-is-executed.html
https://www.developer.com/database/understanding-a-sql-server-query-execution-plan/
The serendipity trap:
the EXPLAIN command (Oh I can’t wait to try that one!)
Locks and Deadlocks (this, I NEED to look into it)
What a great way to overcome the fear of SQL! :)
For me it was hours of frustration until I figured out the basics of a join query, which is also a whole system by itself.
By the way, keep up the personal writing!
It's so refreshing to see a new newsletter that's not written by ChatGPT :)