On Mon, Nov 14, 2011 at 5:22 PM, Andrew Barnham
<andrew.barnham@gmail.com> wrote:
> I wonder, if it is possible and worthwhile, to setup the query planner to
> recognize that because of the stats I indicate above, that a sort by partnum
> is almost exactly the same as a sort by partnum+franchise. And doing a
> Index scan on partnum index, and sorting results in memory will be
> dramatically faster. The sort buffer only needs to be very small, will only
> grow to 8 records only at most in my above example. The buffer will scan
> partnum index, and as long as partnum is the same, it will sort that small
> segment, as soon as the partnum increments when walking the index, the
> buffer zeros out again for next sort group.
This has come up before and seems worthwhile, but nobody's implemented it yet.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company