Re: Specifying many rows in a table - Mailing list pgsql-general

From Tom Lane
Subject Re: Specifying many rows in a table
Date
Msg-id 9681.1075340027@sss.pgh.pa.us
Whole thread Raw
In response to Re: Specifying many rows in a table  (Steve Atkins <steve@blighty.com>)
List pgsql-general
Steve Atkins <steve@blighty.com> writes:
> An interesting thing, though is that for 10,000,000 rows in big and
> one row in little, everything indexed and analyzed an exists query
> is painfully bad...

>   select * from big where exists (select 1 from little where s=big.id)

> ...expands to nested seqscans over big and little, rather than the
> seqscan over little with a nested index scan over big I was expecting.

The planner can figure this out for straight join and (as of 7.4) for
IN, but not for EXISTS().  I've forgotten the details, but there were
some semantic fine points that discouraged me from trying to tackle the
EXISTS() case at the same time as IN.

            regards, tom lane

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: Specifying many rows in a table
Next
From: Craig Addleman
Date:
Subject: Pl/tcl auto-load problem