From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Claudio Freire <klaussfreire(at)gmail(dot)com> |
Cc: | Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>, Ivan Voras <ivoras(at)freebsd(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, postgres performance list <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: ORDER BY, LIMIT and indexes |
Date: | 2013-08-07 04:52:58 |
Message-ID: | 3619.1375851178@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Claudio Freire <klaussfreire(at)gmail(dot)com> writes:
> Alternatively, a token startup cost could be added to those kinds of
> filtered sequential scans, when the filtering term is selective
> enough. That would offset the cost just a little bit, but enough to
> favor index over sequential on the right cases.
Maybe not so "token". Really, if there's a filter condition having a
selectivity of say 1/N, we should expect to have to skip over O(N) tuples
before finding a match. (Not sure at this late hour if the expectation is
N, or N/2, or something else ... but anyway it's in that ballpark.) We
don't take that into account in computing the startup time of a plan node,
but I'm thinking we should. In this particular example, that would
penalize the seqscan plan and not the indexscan plan, because in the
indexscan case the condition is being applied by the index; it's not an
after-the-fact filter.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | slapo | 2013-08-07 12:42:39 | Re: [PERFORM] Sub-optimal plan for a paginated query on a view with another view inside of it. |
Previous Message | Sergey Konoplev | 2013-08-07 00:00:22 | Re: ORDER BY, LIMIT and indexes |