Install any skill in seconds. Free to start, no credit card required.
Get Started Free →PostgreSQL best practices for query optimization, schema design, indexing, and row-level security, with quick-reference tables.
95% 100%+5 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 21 of 22 without it.
我正在建立電子商務系統的訂單資料表,包含主鍵識別碼、客戶識別碼、訂單狀態、建立時間、總金額(需防止精確度誤差),以及 JSON 擴充欄位。請幫我編寫 PostgreSQL 的 DDL,並為「特定狀態加時間範圍」查詢情境設計最合適的索引定義。
Uses text data type for the order status string column instead of varchar
3 of 3 safety checks passed
PostgreSQL 最佳實務快速參考。詳細指南請使用 database-reviewer agent。
| 查詢模式 | 索引類型 | 範例 |
|---|---|---|
WHERE col = value | B-tree(預設) | CREATE INDEX idx ON t (col) |
WHERE col > value | B-tree | CREATE INDEX idx ON t (col) |
WHERE a = x AND b > y | 複合 | CREATE INDEX idx ON t (a, b) |
WHERE jsonb @> '{}' | GIN | CREATE INDEX idx ON t USING gin (col) |
WHERE tsv @@ query | GIN | CREATE INDEX idx ON t USING gin (col) |
| 時間序列範圍 | BRIN | CREATE INDEX idx ON t USING brin (col) |
| 使用情況 | 正確類型 | 避免 |
|---|---|---|
| IDs | bigint | int、隨機 UUID |
| 字串 | text | varchar(255) |
| 時間戳 | timestamptz | timestamp |
| 金額 | numeric(10,2) | float |
| 旗標 | boolean | varchar、int |
複合索引順序:
-- 等值欄位優先,然後是範圍欄位
Published skills whose descriptions closely match this one, with their benchmark result.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.