Section: IT & Technology · DatabasesDifficulty: Advanced

Query Optimization

USUK

The process of selecting the most efficient execution plan for a database query to minimize resource usage.

Definition

Query optimization is the process by which a database management system determines the most efficient way to execute a SQL query by selecting the optimal execution plan from many possible alternatives. The query optimizer considers available indexes, statistics about data distribution, join algorithms, and execution costs. Database administrators can improve query performance by analyzing query execution plans (EXPLAIN), adding indexes, rewriting queries, updating statistics, and partitioning large tables.

Example

A query taking 30 seconds is reduced to 0.1 seconds after adding a composite index on (customer_id, order_date) and rewriting a subquery as a JOIN.

Synonyms

  • query tuning
  • SQL optimization
  • execution plan optimization

Antonyms / Opposites

  • inefficient query
  • unoptimized query

Images

CC-licensed · free to use
More on Wikimedia
Loading images…

Video

  • indexing
  • sql
  • execution-plan
  • database-performance

Dictionary Entry

Back to IT & Technology