【发布时间】:2020-04-27 16:16:13
【问题描述】:
我有一张桌子:
row_id attr_id attr_val
180000001 100 test1
180000001 101 test2
180000001 102 test3
180000001 103 test4
180000001 104 test5
180000002 100 test6
180000002 101 test7
180000002 102 test8
180000002 103 test9
180000002 104 test10
它有超过 50 亿行,表大小约为 1.4 TB。我通常运行以下查询:
select * from table1 where rec_id = 180000002;
和
select * from table1 where rec_id = 180000002 and va_id = 100;
考虑到空间和我的用例,我应该在 Postgres 中应用哪种类型的索引才能最有效?
【问题讨论】:
-
rec_id或row_id?va_id或attr_id?
标签: sql postgresql where-clause query-performance