postgres-code-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePostgreSQL Code Review
PostgreSQL代码评审
Quick Reference
快速参考
| Issue Type | Reference |
|---|---|
| Missing indexes, wrong index type, query performance | references/indexes.md |
| JSONB queries, operators, GIN indexes | references/jsonb.md |
| Connection leaks, pool configuration, timeouts | references/connections.md |
| Isolation levels, deadlocks, advisory locks | references/transactions.md |
| 问题类型 | 参考文档 |
|---|---|
| 缺失索引、索引类型错误、查询性能问题 | references/indexes.md |
| JSONB查询、操作符、GIN索引 | references/jsonb.md |
| 连接泄漏、池配置、超时 | references/connections.md |
| 隔离级别、死锁、咨询锁 | references/transactions.md |
Review Checklist
评审检查清单
- WHERE/JOIN columns have appropriate indexes
- Composite indexes match query patterns (column order matters)
- JSONB columns use GIN indexes when queried
- Using proper JSONB operators (,
->,->>,@>)? - Connection pool configured with appropriate limits
- Connections properly released (context managers, try/finally)
- Appropriate transaction isolation level for use case
- No long-running transactions holding locks
- Advisory locks used for application-level coordination
- Queries use parameterized statements (no SQL injection)
- WHERE/JOIN列拥有合适的索引
- 复合索引匹配查询模式(列顺序很重要)
- 查询JSONB列时使用GIN索引
- 使用正确的JSONB操作符(,
->,->>,@>)? - 连接池配置了合适的限制
- 连接已正确释放(使用上下文管理器、try/finally)
- 为场景配置合适的事务隔离级别
- 不存在持有锁的长事务
- 使用咨询锁进行应用级协调
- 查询使用参数化语句(避免SQL注入)
When to Load References
何时查阅参考文档
- Reviewing SELECT queries with WHERE/JOIN → indexes.md
- Reviewing JSONB columns or JSON operations → jsonb.md
- Reviewing database connection code → connections.md
- Reviewing BEGIN/COMMIT or concurrent updates → transactions.md
- 评审带WHERE/JOIN的SELECT查询 → indexes.md
- 评审JSONB列或JSON操作 → jsonb.md
- 评审数据库连接代码 → connections.md
- 评审BEGIN/COMMIT或并发更新 → transactions.md
Review Questions
评审问题
- Will this query use an index or perform a sequential scan?
- Are JSONB operations using appropriate operators and indexes?
- Are database connections properly managed and released?
- Is the transaction isolation level appropriate for this operation?
- Could this cause deadlocks or long-running locks?
- 该查询会使用索引还是执行全表扫描?
- JSONB操作是否使用了合适的操作符和索引?
- 数据库连接是否得到正确管理和释放?
- 事务隔离级别是否适合该操作?
- 这是否会导致死锁或长期持有锁?