编程prompt-architects.com · 收录于
检查 SQL 查询的索引使用、结果集限制、循环查询、批量更新删除及 NULL 语义问题
完整提示词
Check for: - Predicates that cannot use an index (leading wildcard, function on the column, implicit cast) - Missing index for the WHERE, JOIN or ORDER BY columns used here - Unbounded result sets with no LIMIT and no pagination - Query shapes the caller will execute in a loop (N+1) - UPDATE or DELETE with a WHERE that can match every row - SQL assembled by string concatenation instead of parameters - NULL semantics: NOT IN against a nullable subquery, `= NULL`
使用说明
复制全文后,按自己的场景替换占位变量(方括号 / 双花括号包裹的字段)再使用。 部分提示词依赖特定模型或工具(如 GPT / Claude / Copilot),请根据实际情况调整。