query_plan.txt

text/plain

Filename: query_plan.txt
Type: text/plain
Part: 4
Message: Queries containing ORDER BY and LIMIT started to work slowly
                                                                             QUERY PLAN                                                                          
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
     Limit  (cost=1048379.37..1048428.33 rows=100 width=498) (actual time=5264.193..5264.444 rows=100 loops=1)
       Buffers: shared hit=40250 read=332472, temp read=16699 written=28392
       ->  Merge Join  (cost=1048379.37..2291557.51 rows=2539360 width=498) (actual time=5264.191..5264.436 rows=100 loops=1)
             Merge Cond: ((books.isbn)::text = (isbns.value)::text)
             Buffers: shared hit=40250 read=332472, temp read=16699 written=28392
             ->  Index Scan using books_isbn_key on books  (cost=0.43..1205494.88 rows=1386114 width=333) (actual time=0.020..0.150 rows=100 loops=1)
                   Buffers: shared hit=103
             ->  Materialize  (cost=1042333.77..1055199.75 rows=2573197 width=155) (actual time=5263.901..5263.960 rows=100 loops=1)
                   Buffers: shared hit=40147 read=332472, temp read=16699 written=28392
                   ->  Sort  (cost=1042333.77..1048766.76 rows=2573197 width=155) (actual time=5263.895..5263.949 rows=100 loops=1)
                         Sort Key: isbns.value
                         Sort Method: external merge  Disk: 136864kB
                         Buffers: shared hit=40147 read=332472, temp read=16699 written=28392
                         ->  Hash Join  (cost=55734.14..566061.44 rows=2573197 width=155) (actual time=403.962..1994.884 rows=1404582 loops=1)
                               Hash Cond: (isbns_statistics.isbn_id = isbns.id)
                               Buffers: shared hit=40147 read=332472, temp read=11281 written=11279
                               ->  Seq Scan on isbns_statistics  (cost=0.00..385193.97 rows=2573197 width=120) (actual time=0.024..779.717 rows=1404582 loops=1)
                                     Buffers: shared hit=26990 read=332472
                               ->  Hash  (cost=27202.84..27202.84 rows=1404584 width=35) (actual time=402.431..402.431 rows=1404584 loops=1)
                                     Buckets: 1048576  Batches: 2  Memory Usage: 51393kB
                                     Buffers: shared hit=13157, temp written=4363
                                     ->  Seq Scan on isbns  (cost=0.00..27202.84 rows=1404584 width=35) (actual time=0.027..152.568 rows=1404584 loops=1)
                                           Buffers: shared hit=13157
     Planning time: 1.160 ms
     Execution time: 5279.983 ms
    (25 rows)