Skip navigation
Visualizing a SQL query in 5 mins
0:00 / 5:48

Visualizing a SQL query in 5 mins

Alex Xu

@alexxubyte295K followers

Visit on X
370 likesDownloadOriginal post

23,200 views

Visualizing a SQL query in 5 mins SQL statements are executed by the database system in several steps, including: - Parsing the SQL statement and checking its validity - Transforming the SQL into an internal representation, such as relational algebra - Optimizing the internal representation and creating an execution plan that utilizes index information - Executing the plan and returning the results

7 Comments

Comments from the original post on X (Twitter)

  • Petar Ivanov's profile picture

    @petarivanovv9

    @bytebytego @sahnlam I always find it eye-opening to peek at actual execution plans in the database console. That moment when you spot an unexpected table scan is humbling. 💪

    3 likes

  • Adel Bucetta's profile picture

    @adelbucetta

    @bytebytego @sahnlam the hard part is understanding which optimization to choose, not just transforming sql into algebra, that's a solved problem

  • Derrick Simpson's profile picture

    @DerrickLSimpson

    @bytebytego @sahnlam Also, "Predicate Pushdown" can allow filtering and removal of rows prior to a join. All records are not always joined/merged prior to filtering.

  • Buswe's profile picture

    @buswe_com

    @bytebytego @sahnlam EXPLAIN ANALYZE remata bien ese recorrido: enseña filas y tiempos reales de cada paso, no solo el plan estimado.

  • Trebor's profile picture

    @TreborJoss

    @bytebytego @sahnlam Btw, great overview.

  • TechP's profile picture

    @Tech_p001

    @bytebytego @sahnlam Thanks for sharing this wonderful insight Very helpful

  • Trebor's profile picture

    @TreborJoss

    @bytebytego @sahnlam Execution plan also considers histogram statistics to determine and use more efficient execution plans. An example is to skip using an index when a full tab scan would be less costly.