было?
# EXPLAIN (ANALYZE, BUFFERS) SELECT panels.* FROM panels INNER JOIN olympiad_groups ON olympiad_groups.id = panels.olympiad_group_id INNER JOIN olympiads ON olympiads.olympiad_group_id = olympiad_groups.id WHERE panels.kind IN ('dino', 'biz', 'rus', 'sa_plus', 'sbrf', 'kbr', 'math_high', 'rus_high', 'eng_high', 'zmath', 'zrus', 'zeng', 'zprog', 'junior_plus', 'high_plus', 'brics_olymp', 'dv', 'zmath_ad') AND panels.show = 't' AND (olympiad_groups.live is true AND 9 = ANY(olympiad_groups.subject_ids) AND olympiads.grade_value = 11);
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost=2.26..17.32 rows=1 width=2125) (actual time=0.082..0.082 rows=0 loops=1)
Buffers: shared hit=14
-> Hash Join (cost=2.12..13.59 rows=1 width=2129) (actual time=0.046..0.072 rows=2 loops=1)
Hash Cond: (olympiads.olympiad_group_id = panels.olympiad_group_id)
Buffers: shared hit=10
-> Seq Scan on olympiads (cost=0.00..11.44 rows=5 width=4) (actual time=0.014..0.040 rows=5 loops=1)
Filter: (grade_value = 11)
Rows Removed by Filter: 190
Buffers: shared hit=9
-> Hash (cost=2.01..2.01 rows=9 width=2125) (actual time=0.023..0.023 rows=7 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 10kB
Buffers: shared hit=1
-> Seq Scan on panels (cost=0.00..2.01 rows=9 width=2125) (actual time=0.011..0.019 rows=8 loops=1)
Filter: (show AND ((kind)::text = ANY ('{dino,biz,rus,sa_plus,sbrf,kbr,math_high,rus_high,eng_high,zmath,zrus,zeng,zprog,junior_plus,high_plus,brics_olymp,dv,zmath_ad}'::text[])))
Rows Removed by Filter: 25
Buffers: shared hit=1
-> Index Scan using olympiad_groups_pkey on olympiad_groups (cost=0.14..3.73 rows=1 width=4) (actual time=0.005..0.005 rows=0 loops=2)
Index Cond: (id = panels.olympiad_group_id)
Filter: ((live IS TRUE) AND (9 = ANY (subject_ids)))
Rows Removed by Filter: 1
Buffers: shared hit=4
Planning time: 0.241 ms
Execution time: 0.119 ms
(23 rows)
> Execution time: 0.119 ms А что Вас не устраивает-то?
я бы panels.kind IN (...) перевернул на джоин. но боюсь на скорость никак не повлияет.
Обсуждают сегодня