SQL Query Optimization

Introduction to Query Optimization

  • Query optimization is a difficult part of the query processing.
  • It determines the efficient way to execute a query with different possible query plans.
  • It cannot be accessed directly by users once the queries are submitted to the database server or parsed by the parser.
  • A query is passed to the query optimizer where optimization occurs.
  • Main aim of Query Optimization is to minimize the cost function,
    I/O Cost + CPU Cost + Communication Cost
  • It defines how an RDBMS can improve the performance of the query by re-ordering the operations.
  • It is the process of selecting the most efficient query evaluation plan from among various strategies if the query is complex.
  • It computes the same result as per the given expression, but it is a least costly way of generating result.

Importance of Query Optimization

  • Query optimization provides faster query processing.
  • It requires less cost per query.
  • It gives less stress to the database.
  • It provides high performance of the system.
  • It consumes less memory.