achfrag.net/2025/06/03/art-of-query-optimization.html

Preview meta tags from the achfrag.net website.

Linked Hostnames

13

Thumbnail

Search Engine Appearance

Google

https://achfrag.net/2025/06/03/art-of-query-optimization.html

The Art of SQL Query Optimization

SQL is a declarative language; only the result of the query is specified. The exact steps to produce the result must be determined by the DBMS. Often, multiple ways exist to calculate a query result. For example, the DBMS can choose to use an index or perform a sequential scan on a table to find the needed tuples. The query optimizer is responsible for finding the most efficient plan for a given query. The plan generator creates possible plans, which are then evaluated based on their costs. Afterward, the cheapest plan is chosen and executed. When the DBMS expects to return a large portion of the table, a full table scan can be more efficient than following the pointers in an index structure. However, it is hard to determine when the DBMS prefers one plan over another and when the switch between plans occurs. In a few evenings, I implemented the plan explorer for PostgreSQL. It iterates over a search space and generates visualizations that show when the plan changes and how many tuples are expected versus the actual number returned. This blog post examines the “art” of query optimization. It discusses the plan explorer tool, the images the tool generates, and the insights the tool provides into the decisions made by the PostgreSQL query optimizer.



Bing

The Art of SQL Query Optimization

https://achfrag.net/2025/06/03/art-of-query-optimization.html

SQL is a declarative language; only the result of the query is specified. The exact steps to produce the result must be determined by the DBMS. Often, multiple ways exist to calculate a query result. For example, the DBMS can choose to use an index or perform a sequential scan on a table to find the needed tuples. The query optimizer is responsible for finding the most efficient plan for a given query. The plan generator creates possible plans, which are then evaluated based on their costs. Afterward, the cheapest plan is chosen and executed. When the DBMS expects to return a large portion of the table, a full table scan can be more efficient than following the pointers in an index structure. However, it is hard to determine when the DBMS prefers one plan over another and when the switch between plans occurs. In a few evenings, I implemented the plan explorer for PostgreSQL. It iterates over a search space and generates visualizations that show when the plan changes and how many tuples are expected versus the actual number returned. This blog post examines the “art” of query optimization. It discusses the plan explorer tool, the images the tool generates, and the insights the tool provides into the decisions made by the PostgreSQL query optimizer.



DuckDuckGo

https://achfrag.net/2025/06/03/art-of-query-optimization.html

The Art of SQL Query Optimization

SQL is a declarative language; only the result of the query is specified. The exact steps to produce the result must be determined by the DBMS. Often, multiple ways exist to calculate a query result. For example, the DBMS can choose to use an index or perform a sequential scan on a table to find the needed tuples. The query optimizer is responsible for finding the most efficient plan for a given query. The plan generator creates possible plans, which are then evaluated based on their costs. Afterward, the cheapest plan is chosen and executed. When the DBMS expects to return a large portion of the table, a full table scan can be more efficient than following the pointers in an index structure. However, it is hard to determine when the DBMS prefers one plan over another and when the switch between plans occurs. In a few evenings, I implemented the plan explorer for PostgreSQL. It iterates over a search space and generates visualizations that show when the plan changes and how many tuples are expected versus the actual number returned. This blog post examines the “art” of query optimization. It discusses the plan explorer tool, the images the tool generates, and the insights the tool provides into the decisions made by the PostgreSQL query optimizer.

  • General Meta Tags

    9
    • title
      The Art of SQL Query Optimization | Jan’s website and blog
    • charset
      utf-8
    • viewport
      width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=5
    • generator
      Jekyll v3.10.0
    • author
      Jan Nidzwetzki
  • Open Graph Meta Tags

    8
    • og:image
      https://jnidzwetzki.github.io/assets/img/plan_explorer_query2.svg
    • og:type
      website
    • og:title
      The Art of SQL Query Optimization
    • US country flagog:locale
      en_US
    • og:description
      SQL is a declarative language; only the result of the query is specified. The exact steps to produce the result must be determined by the DBMS. Often, multiple ways exist to calculate a query result. For example, the DBMS can choose to use an index or perform a sequential scan on a table to find the needed tuples. The query optimizer is responsible for finding the most efficient plan for a given query. The plan generator creates possible plans, which are then evaluated based on their costs. Afterward, the cheapest plan is chosen and executed. When the DBMS expects to return a large portion of the table, a full table scan can be more efficient than following the pointers in an index structure. However, it is hard to determine when the DBMS prefers one plan over another and when the switch between plans occurs. In a few evenings, I implemented the plan explorer for PostgreSQL. It iterates over a search space and generates visualizations that show when the plan changes and how many tuples are expected versus the actual number returned. This blog post examines the “art” of query optimization. It discusses the plan explorer tool, the images the tool generates, and the insights the tool provides into the decisions made by the PostgreSQL query optimizer.
  • Twitter Meta Tags

    6
    • twitter:card
      summary
    • twitter:title
      The Art of SQL Query Optimization
    • twitter:description
      SQL is a declarative language; only the result of the query is specified. The exact steps to produce the result must be determined by the DBMS. Often, multip...
    • twitter:card
      summary
    • twitter:image
      https://jnidzwetzki.github.io/assets/img/plan_explorer_query2.svg
  • Link Tags

    5
    • alternate
      https://jnidzwetzki.github.io/feed.xml
    • alternate
      https://jnidzwetzki.github.io/feed.xml
    • canonical
      https://jnidzwetzki.github.io/2025/06/03/art-of-query-optimization.html
    • shortcut icon
      /assets/favicon.ico
    • stylesheet
      /assets/css/main.css

Emails

1

Links

29