I profiled this on CVS HEAD. First, I set this up:
> postgres=# create table tk as select
random()::text||random()::text||random()::text||random()::text||random()::text||random()::textas r from
generate_series(1,1000);
> postgres=# insert into tk (select * from tk);
> postgres=# insert into tk (select * from tk);
> postgres=# insert into tk (select
random()::text||random()::text||random()::text||random()::text||random()::text||random()::textas r from
generate_series(1,2000));
> postgres=# alter table tk alter r set statistics 1000;
> postgres=# analyze tk;
Then I profiled a backend that executed the following query 10x
(uparrow-enter 10 times from psql):
> postgres=# explain select count(*) from (select * from tk as k, tk as l,tk as m,tk as n,tk as o,tk as p where k.r=l.r
andk.r=m.r and k.r=n.r and k.r=o.r and k.r=p.r) as x;
Results:
% cumulative self self total
time seconds seconds calls s/call s/call name
77.73 1.92 1.92 5500 0.00 0.00 pglz_decompress
6.07 2.07 0.15 250 0.00 0.00 eqjoinsel
1.62 2.11 0.04 2009500 0.00 0.00 varstr_cmp
1.21 2.14 0.03 3502500 0.00 0.00 datumCopy
1.21 2.17 0.03 3500 0.00 0.00 deconstruct_array
1.21 2.20 0.03 MemoryContextContains
Full results attached.
...Robert