Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
Query analysis is a process used in databases which make use of SQL in order to determine how to further optimize queries for performance.
Query analysis is an important aspect of query processing as it helps improve overall performance of query processing, which will speed up many database functions and aspects. To do this, a query optimizer analyzes a specific query statement and generates both remote and local access plans to be used on the query fragment, based on the resource cost of each plan.
The database will then choose whichever plan it believes will process the query with the least cost in resources.
In general, SQL queries are generated by applications and users are then sent to a federated database in order to retrieve data from sources. Based on the query statement, the SQL compiler then consults the data source wrapper and the information stored on the global catalog in order to help it process the query.
The information it retrieves include the data source, mappings, data and server attributes, nicknames, statistics and more. The query optimizer which facilitates the query analysis is actually part of the SQL compiler process.
Through the query optimizer, the compiler develops different plans, alternative strategies that can be used when processing the query. These are called access plans and they might call for the query to be processed by different elements.
These elements are:
The federated server
The data sources
A little bit of both
On relational databases, a pushdown analysis is performed. It determines which operations can be evaluated remotely based on the query statement and the knowledge it has of the capabilities of the data sources. Based on the results of this analysis, the query optimizer will choose the best access plan with the least resource cost.