Tell me about how you would review SQL data structures for correctness and performance.
Using the supplied PostgreSQL metadata snapshot, identify tables that need structural or performance review. Include key metadata and scan statistics so the findings can be investigated.
Output
- One row per table requiring review.
- Include
table_name, correctness and performance statuses, primary-key counts, and scan counts.
- Sort alphabetically by
table_name.
Output details
- Return columns in this order:
table_name, correctness_status, performance_status, primary_key_count, nullable_primary_key_count, sequential_scans, index_scans.
- Mark correctness
REVIEW when a required primary key is absent or any primary key is nullable; otherwise mark it OK.
- Mark performance
REVIEW when row_count >= 10000 and sequential_scans exceeds twice GREATEST(index_scans, 1); otherwise mark it OK.