Как заставит Postgres выбирать первичный индекс а не фильтр?
Как заставит Postgres выбирать первичный индекс а не фильтр? Т/е во втором варианте очень медленно выбираются данный
p.s. это часть большого запроса
1)explain select min(thm_start_date) from themes where themes.cmp_id=11;
QUERY PLAN
--------------------------------------------------------------------------------------
Aggregate (cost=3284.01..3284.01 rows=1 width=4)
-> Index Scan using contains_fk on themes (cost=0.00..3281.15 rows=1145 width=4)
Index Cond: (cmp_id = 11)
(3 rows)
2)explain select min(thm_start_date) from themes where themes.cmp_id=12;
QUERY PLAN
---------------------------------------------------------------------
Aggregate (cost=21056.12..21056.12 rows=1 width=4)
-> Seq Scan on themes (cost=0.00..20682.09 rows=149615 width=4)
Filter: (cmp_id = 12)
Как заставит Postgres выбирать первичный индекс а не фильтр? Т/е во втором варианте очень медленно выбираются данный
p.s. это часть большого запроса
1)explain select min(thm_start_date) from themes where themes.cmp_id=11;
QUERY PLAN
--------------------------------------------------------------------------------------
Aggregate (cost=3284.01..3284.01 rows=1 width=4)
-> Index Scan using contains_fk on themes (cost=0.00..3281.15 rows=1145 width=4)
Index Cond: (cmp_id = 11)
(3 rows)
2)explain select min(thm_start_date) from themes where themes.cmp_id=12;
QUERY PLAN
---------------------------------------------------------------------
Aggregate (cost=21056.12..21056.12 rows=1 width=4)
-> Seq Scan on themes (cost=0.00..20682.09 rows=149615 width=4)
Filter: (cmp_id = 12)