Pager usage is off. SET QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=5353.71..5353.72 rows=1 width=64) (actual time=10607.642..10607.644 rows=1.00 loops=1) Buffers: shared hit=22223141 read=1381834 -> Nested Loop (cost=9.37..5337.88 rows=3165 width=33) (actual time=2.503..9525.673 rows=3710592.00 loops=1) Join Filter: (an.person_id = n.id) Buffers: shared hit=22223141 read=1381834 -> Nested Loop (cost=8.95..4667.49 rows=1378 width=25) (actual time=2.490..6179.436 rows=2832555.00 loops=1) Buffers: shared hit=11897439 read=1107501 -> Nested Loop (cost=8.52..4048.53 rows=1378 width=21) (actual time=2.481..3069.508 rows=2832555.00 loops=1) Join Filter: (ci.movie_id = t.id) Buffers: shared hit=3159885 read=751362 -> Nested Loop (cost=8.08..3929.09 rows=63 width=29) (actual time=2.245..937.683 rows=68316.00 loops=1) Buffers: shared hit=815660 read=146762 -> Nested Loop (cost=7.66..3850.15 rows=177 width=33) (actual time=2.224..598.822 rows=148552.00 loops=1) Join Filter: (mc.movie_id = t.id) Buffers: shared hit=295838 read=72376 -> Nested Loop (cost=7.23..3829.71 rows=34 width=25) (actual time=2.185..494.519 rows=41840.00 loops=1) Buffers: shared hit=125415 read=54538 -> Nested Loop (cost=6.80..3813.14 rows=34 width=4) (actual time=2.177..346.122 rows=41840.00 loops=1) Buffers: shared hit=24 read=12569 -> Seq Scan on keyword k (cost=0.00..2685.11 rows=1 width=4) (actual time=0.382..7.022 rows=1.00 loops=1) Filter: (keyword = 'character-name-in-title'::text) Rows Removed by Filter: 134168 Buffers: shared hit=22 read=986 -> Bitmap Heap Scan on movie_keyword mk (cost=6.80..1124.98 rows=305 width=8) (actual time=1.794..336.613 rows=41840.00 loops=1) Recheck Cond: (k.id = keyword_id) Heap Blocks: exact=11547 Buffers: shared hit=2 read=11583 -> Bitmap Index Scan on keyword_id_movie_keyword (cost=0.00..6.72 rows=305 width=0) (actual time=0.965..0.965 rows=41840.00 loops=1) Index Cond: (keyword_id = k.id) Index Searches: 1 Buffers: shared hit=2 read=36 -> Index Scan using title_pkey on title t (cost=0.43..0.49 rows=1 width=21) (actual time=0.003..0.003 rows=1.00 loops=41840) Index Cond: (id = mk.movie_id) Index Searches: 41840 Buffers: shared hit=125391 read=41969 -> Index Scan using movie_id_movie_companies on movie_companies mc (cost=0.43..0.54 rows=5 width=8) (actual time=0.002..0.002 rows=3.55 loops=41840) Index Cond: (movie_id = mk.movie_id) Index Searches: 41840 Buffers: shared hit=170423 read=17838 -> Index Scan using company_name_pkey on company_name cn (cost=0.42..0.45 rows=1 width=4) (actual time=0.002..0.002 rows=0.46 loops=148552) Index Cond: (id = mc.company_id) Filter: ((country_code)::text = '[us]'::text) Rows Removed by Filter: 1 Index Searches: 148552 Buffers: shared hit=519822 read=74386 -> Index Scan using movie_id_cast_info on cast_info ci (cost=0.44..1.40 rows=40 width=8) (actual time=0.003..0.029 rows=41.46 loops=68316) Index Cond: (movie_id = mk.movie_id) Index Searches: 68316 Buffers: shared hit=2344225 read=604600 -> Index Only Scan using name_pkey on name n (cost=0.43..0.45 rows=1 width=4) (actual time=0.001..0.001 rows=1.00 loops=2832555) Index Cond: (id = ci.person_id) Heap Fetches: 0 Index Searches: 2832555 Buffers: shared hit=8737554 read=356139 -> Index Scan using person_id_aka_name on aka_name an (cost=0.42..0.46 rows=2 width=20) (actual time=0.001..0.001 rows=1.31 loops=2832555) Index Cond: (person_id = ci.person_id) Index Searches: 2832555 Buffers: shared hit=10325702 read=274333 Planning: Buffers: shared hit=550 read=125 Planning Time: 4.686 ms Execution Time: 10607.707 ms (62 rows)