> > I have had more time to think about this. Basically, for pre-sorted
> > data, our psort code is very fast, because it does not need to sort
> > anything. It just moves the rows in and out of the sort memory. Yes,
> > it could be removed in some cases, and probably should be, but it is not
> > going to produce great speedups.
>
> And I got the time to hack around about this.
>
> I hacked in a little check into the planner, that compares
> the sortClause against the key field list of an index scan
> and just suppresses the sort node if it exactly matchs and
> all sort operators are "<".
>
> I tested with a 10k row table where key is a text field. The
> base query is a
>
> SELECT ... WHERE key > 'val' ORDER BY key;
>
> The used 'val' is always a key that is close to the first of
> all keys in the table ('' on the first query and the last
> selected value on subsequent ones).
This is good stuff. I want to think about it for a day. Sounds very
promising.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026