Re: Sorting a query on a view ignores an index - Mailing list pgsql-performance

From Your Name
Subject Re: Sorting a query on a view ignores an index
Date
Msg-id E19pvmT-0003kE-Dw@viper.rx2.net
Whole thread Raw
In response to Sorting a query on a view ignores an index  (Mathieu De Zutter <mathieu@dezutter.org>)
List pgsql-performance
> Apart from avoiding views or subselects when sorting afterwards and
> putting the whole bunch in a huge SQL statement (which i'll have to
> produce on-the-fly), do you have an other alternative?
> The 2 seconds is way to much, as the database will eventually run on a
> machine that is 10 times slower.

Something that isn't _totally_ clear is whether or not it is going to
be possible to make use of indices in the selection.  If the postmaster
must assemble, out of disparate sources, a large collection of data,
the best trade-off may very well be to build the collection the best
way the system knows how (perhaps NOT ordering this using the index you
expect), and sort it afterwards.

Sorting doesn't tend to be grieviously expensive except when finding
the query results is also grieviously expensive.

I think you are assuming that the query would be quicker if it used the
sorted index; that is an assumption that should be checked at the door,
or at least checked somewhere.
--
"The main difference between an amateur crypto designer and a used car
salesman is that  the used car salesman can  probably drive and  knows
when he's lying." -- An Metet <anmetet@freedom.gmsociety.org>

pgsql-performance by date:

Previous
From: Bill Moran
Date:
Subject: Re: Tests
Next
From: Mathieu De Zutter
Date:
Subject: Re: Sorting a query on a view ignores an index