> But, you are correct that certain cases where in index is already being
> used on a query, you could just skip the sort IF you used the index to
> get the rows from the base table.
Especially in the case where
SELECT ... WHERE key > 'val' ORDER BY key;
creates a Sort->IndexScan plan. The index scan already jumps
around on the disc to collect the sorts input and the sort
finally returns exactly the same output (if the used index is
only on key).
And this is the case for large tables. The planner first
decides to use an index scan due to the WHERE clause and
later it notices the ORDER BY clause and creates a sort over
the scan.
I'm actually hacking around on it to see what happens if I
suppress the sort node in some cases.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #