การเพิ่มประสิทธิภาพคิวรีใน PostgreSQL
Amy McCarty
Instructor
คืออะไร
ทำไมต้องใช้
ใช้ที่ไหน
| ingredient | recipe |
|---|---|
| tomatoes | spaghetti & meatballs |
| green onions | fried rice |
| eggs | fried rice |
| ground beef | spaghetti & meatballs |
| pasta | spaghetti & meatballs |
| rice | fried rice |
| soy sauce | fried rice |
SELECT *
FROM cookbook
WHERE recipe = 'fried rice'

SELECT * FROM pg_indexes
| schemaname | tablename | indexname | tablespace | indexdef |
|---|---|---|---|---|
| food | dinner | recipe_index | null | CREATE INDEX recipe_index ... |

CREATE INDEX recipe_index
ON cookbook (recipe);
CREATE INDEX CONCURRENTLY recipe_index
ON cookbook (recipe, serving_size);
ควรใช้ดัชนี
ไม่ควรใช้ดัชนี
ตารางที่อัปเดตบ่อย

Query planner
EXPLAIN
SELECT *
FROM cookbook
Query Plan
Seq scan on cookbook (cost=0.00...22.70
rows = 1270 width = 36)
การเพิ่มประสิทธิภาพคิวรีใน PostgreSQL