QUERY OPTIMISATION.
This is the process of improving the performance of a query by transforming it.
WAYS TO QUERY OPTIMISATION.
1. Use of indexes
2. Using the right data types
3. Use of temporary tables
4. Limiting the data set size
5. Minimizing subqueries
GOALS FOR OPTIMIZING QUERIES.
1. Reduce query execution time
2. Minimize resource usage
3. Increase throughput
TYPES OF QUERY OPTIMIZATION
1. Rule-based optimization (RBO); Rule-based optimizers apply predefined transformation rules to
rewrite the query in a potentially more efficient form. For example, a rule might specify that a
WHERE clause should be applied as early as possible in the query to reduce the dataset size.
2. Cost-based optimization (CBO); cost-based optimizers are used to calculate the cost of multiple
query plans.
3. Heuristic optimization; this approach combines both ROB and CBO.
CHALLENGES IN QUERY OPTIMIZATION
1. Exponential search space
2. Outdated statistics
3. Complex queries
4. Changing data