When a query is fired in a database, it is parsed and validate before retrieving results from database tables. System will automatically construct a query evaluation plan that minimizes the cost of query evaluation. This process of choosing the most appropriate execution strategy for query processing is called query optimization.
SQL queries are translated into equivalent relational algebra expressions before optimization.
Steps to generate query evaluation plans
1)Generate logically equivalent expressions
2)Find alternate query evaluate plans for same expression
3)Estimate cost of each evaluation plan and choose expression with the least estimated cost. Finally, materialized views help to speed up processing certain queries.
Once evaluation plans are generated, estimate the cost using statistical information about the relation sizes and index depths.
How to view query evaluation plans in a database?
explain : PostgreSQL
explain plan for/ select * from table(dbms_xplan.display);-Oracle
set showplan_text on; Execute this and then execute query-SQL Server
To display the details of all insructors who earn a salary LESS than the average salary
Equivalent Relational Algebra Expression
SQL queries are translated into equivalent relational algebra expressions before optimization.
The basic relational algebra operations are −
- Projection
- Selection
- Union
- Intersection
- Minus
- Join
Steps to generate query evaluation plans
1)Generate logically equivalent expressions
2)Find alternate query evaluate plans for same expression
3)Estimate cost of each evaluation plan and choose expression with the least estimated cost. Finally, materialized views help to speed up processing certain queries.
Once evaluation plans are generated, estimate the cost using statistical information about the relation sizes and index depths.
How to view query evaluation plans in a database?
explain
explain plan for/ select * from table(dbms_xplan.display);-Oracle
set showplan_text on; Execute this and then execute query-SQL Server
To display the details of all insructors who earn a salary LESS than the average salary
Equivalent Relational Algebra Expression
query evaluation plan
No comments:
Post a Comment