Middle
What do you look at first when it comes to query planning? What bottlenecks can you see?
sobes.tech AI
Answer from AI
When analyzing a query, I primarily look at:
- Execution plan (EXPLAIN) — to understand how the DBMS plans to execute the query.
- Index usage — checking whether indexes are used or if a full table scan occurs.
- Number of rows returned — a large volume can slow down execution.
- Join types — especially if there are nested loops or inefficient joins.
- Filters and WHERE conditions — how selective and optimal they are.
Potential bottlenecks include:
- Absence or improper use of indexes.
- Full scans of large tables (Full Table Scan).
- Incorrect join order or use of slow JOIN types.
- Redundant or inefficient subqueries.
- Large sorting or aggregation operations without optimization.
Based on this data, you can optimize the query by adding indexes, rewriting logic, or changing the data structure.