Re: why hash on the primary key? - Mailing list pgsql-general

From Robert Haas
Subject Re: why hash on the primary key?
Date
Msg-id 603c8f070811290529r2ee32dceu4ddcd508c8456a02@mail.gmail.com
Whole thread Raw
In response to why hash on the primary key?  ("Robert Haas" <robertmhaas@gmail.com>)
List pgsql-general
> Could you send the output of these two queries using "explain analyze"
> instead of plain explain?

portal=# explain analyze select * from foo i, foo j where i.id = j.id;
                                                       QUERY PLAN

------------------------------------------------------------------------------------------------------------------------
 Hash Join  (cost=747.87..2127.36 rows=13283 width=272) (actual
time=68.434..205.536 rows=13283 loops=1)
   Hash Cond: (i.id = j.id)
   ->  Seq Scan on foo i  (cost=0.00..315.83 rows=13283 width=136)
(actual time=0.024..23.349 rows=13283 loops=1)
   ->  Hash  (cost=315.83..315.83 rows=13283 width=136) (actual
time=68.353..68.353 rows=13283 loops=1)
         ->  Seq Scan on foo j  (cost=0.00..315.83 rows=13283
width=136) (actual time=0.009..23.839 rows=13283 loops=1)
 Total runtime: 223.390 ms
(6 rows)
portal=# set enable_seqscan to false;
SET
portal=# explain analyze select * from foo i, foo j where i.id = j.id;
                                                             QUERY PLAN

------------------------------------------------------------------------------------------------------------------------------------
 Merge Join  (cost=0.00..2310.24 rows=13283 width=272) (actual
time=0.272..149.317 rows=13283 loops=1)
   Merge Cond: (i.id = j.id)
   ->  Index Scan using foo_pkey on foo i  (cost=0.00..1055.50
rows=13283 width=136) (actual time=0.205..29.714 rows=13283 loops=1)
   ->  Index Scan using foo_pkey on foo j  (cost=0.00..1055.50
rows=13283 width=136) (actual time=0.025..37.534 rows=13283 loops=1)
 Total runtime: 166.364 ms
(5 rows)

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: configure options
Next
From: "Robert Haas"
Date:
Subject: Re: why hash on the primary key?