Re: why sequential scan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: newsreader(at)mediaone(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: why sequential scan
Date: 2001-08-16 16:45:28
Message-ID: 10201.997980328@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

newsreader(at)mediaone(dot)net writes:
> I would then iterate over each id I get and
> look up in item like this

> q=> select * from item where item =? order by finish

That's a nestloop join with inner indexscan. The planner did consider
that, and rejected it as slower than the hashjoin it chose. Now,
whether its cost model is accurate for your situation is hard to tell;
but personally I'd bet that it's right. 1500 index probes probably
are slower than a sequential scan over 5000 items.

You could probably force the planner to choose that plan by setting
enable_hashjoin and enable_mergejoin to OFF. It'd be interesting to
see the EXPLAIN result in that situation, as well as actual timings
of the query both ways.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-08-16 16:46:53 Re: confused on maximum characters
Previous Message Justin Clift 2001-08-16 16:33:46 Re: PostgreSQL buffer exploits