планом (users ~1.5M строк):
explain analyze SELECT COUNT(*) AS count FROM "public"."users" WHERE "public"."users"."group_id" = 3 AND "public"."users"."accreditation" = 2 AND "public"."users"."ban_flags" = 0;
QUERY PLAN
—---------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=15050.91..15050.92 rows=1 width=8) (actual time=613.643..613.644 rows=1 loops=1)
-> Index Scan using gid_accr_ban on users (cost=0.43..14983.84 rows=26829 width=0) (actual time=0.064..475.212 rows=166949 loops=1)
Index Cond: ((group_id = 3) AND (accreditation = 2))
Filter: (ban_flags = 0)
Rows Removed by Filter: 11982
Planning time: 0.392 ms
Execution time: 613.727 ms
(7 rows)
добавить в индекс ban_flags? или индекс с where ban_flags=0
Обсуждают сегодня