Re: limit clause breaks query planner? - Mailing list pgsql-performance

From Tom Lane
Subject Re: limit clause breaks query planner?
Date
Msg-id 5925.1220389248@sss.pgh.pa.us
Whole thread Raw
In response to Re: limit clause breaks query planner?  ("Matt Smiley" <mss@rentrak.com>)
Responses Re: limit clause breaks query planner?  ("Matt Smiley" <mss@rentrak.com>)
List pgsql-performance
"Matt Smiley" <mss@rentrak.com> writes:
>  So an Index Scan is always going to have a higher cost estimate than
>  an equivalent Seq Scan returning the same result rows (unless
>  random_page_cost is < 1).  That's why I think the planner is always
>  preferring the plan that uses a Seq Scan.

If that were the case, we'd never choose an indexscan at all...

It's true that a plain indexscan is not preferred for queries that will
return a large fraction of the table.  However, it should be willing to
use a bitmap scan for this query, given default cost settings (the
default cost settings will cause it to prefer bitmap scan for retrieving
up to about a third of the table, in my experience).  I too am confused
about why it doesn't prefer that choice in the OP's example.  It would
be interesting to alter the random_page_cost setting and see if he gets
different results.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Matt Smiley"
Date:
Subject: Re: limit clause breaks query planner?
Next
From: behrangs
Date:
Subject: Re: Samsung 32GB SATA SSD tested