Goal
Evaluate the semantics, compatibility, benefit, and cost of rewrite and index suggestions, then apply them safely after testing and review.Prerequisites
You have completed optimization results with rewrite or index suggestions to evaluate.Decision framework
Evaluating rewrites
When comparing the original and rewritten SQL, focus on:- returned columns, data types, and column order;
NULLsemantics;- duplicate-row and deduplication behavior;
- filter and join conditions;
- aggregation, ordering, pagination, and window functions;
- data-modification scope;
- target database compatibility.
NULL, outer joins, duplicate rows, non-deterministic functions, implicit casts, and DML. Do not adopt a rewrite just because it is shorter or has a lower estimated cost.
Evaluating index recommendations
A recommended index is candidate DDL. When reading its definition, confirm the target table and schema, index type, key columns and order, included columns, filter conditions, uniqueness, and online-creation options. Check its relationship to existing indexes:
Weigh benefit (fewer full scans, fewer rows read, better joins, less sorting, covering queries) against cost (slower writes, storage, creation time, lock impact, maintenance, distributed overhead).
Applying suggestions
1
Validate in a test environment
For rewrites, compare result consistency and check plans; for indexes, create the candidate and compare plans, time, and scan volume.
2
Run performance validation
Use the same environment, data, parameters, and session conditions to compare plans, cost, time, and resources.
3
Submit for review
Attach the original SQL, rationale, test evidence, capacity estimate, window, and rollback plan.
4
Deploy and observe
Apply in the approved window and observe locks, load, space, write latency, and plan changes.
When not to adopt
- SQL or objects did not fully parse;
- workspace does not match the target database;
- the rule rationale or conditions cannot be explained;
- result-consistency testing failed;
- the recommended index duplicates an existing one, or the table has high write pressure with benefit not justifying maintenance cost;
- the database did not actually use the index in the test environment;
- only estimated benefit exists without adequate validation.