Re: Multi ordered select and indexing
| От | Bruno Wolff III | 
|---|---|
| Тема | Re: Multi ordered select and indexing | 
| Дата | |
| Msg-id | 20040423173716.GA7767@wolff.to обсуждение исходный текст | 
| Ответ на | Multi ordered select and indexing ("Antal Attila" <antal.attila@ritek.hu>) | 
| Список | pgsql-sql | 
On Fri, Apr 23, 2004 at 16:33:14 +0200, Antal Attila <antal.attila@ritek.hu> wrote: > > In our experience, postgres cannot use a multi-colum index on (col1, > col2) in this situation, becouse there are different directions after > ORDER BY. Is custom operator class the easiest solution, which can solve > the reverse indexing on col2? Our problem with this solution, is that we > have to replace "DESC" with "USING myoperator". Is it possible, that > postgres can recognize "myoperator" without replacing "DESC"? Another option you might have is using functional indexes. If you are using 7.4.x or greater and one of the columns has a reasonable - operator (pretty much this is the numeric types) then you can have an index on (col1, (-col2)) and then order by col1, -col2. The main advantage is that this is simpler than making a new opclass. If you have already gone to that trouble it may be better to stick with it.
В списке pgsql-sql по дате отправления: