Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D25F347610B for ; Thu, 3 Oct 2002 22:07:37 -0400 (EDT) Received: from field.videotron.net (field.videotron.net [205.151.222.108]) by postgresql.org (Postfix) with ESMTP id 6224E4760CE for ; Thu, 3 Oct 2002 22:07:37 -0400 (EDT) Received: from up4c.com ([24.203.6.93]) by field.videotron.net (Sun Internet Mail Server sims.3.5.1999.12.14.10.29.p8) with ESMTP id <0H3F00E0UPWR5F@field.videotron.net> for pgsql-sql@postgresql.org; Thu, 3 Oct 2002 22:07:40 -0400 (EDT) Date: Thu, 03 Oct 2002 22:07:40 -0400 From: Vincent-Olivier Arsenault Subject: order by x DESC, y ASC indexing problem To: pgsql-sql@postgresql.org Message-id: <3D9CF7EC.8080102@up4c.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Content-transfer-encoding: 7bit User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.2a) Gecko/20020910 X-Accept-Language: en-us, en X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/45 X-Sequence-Number: 9763 Hello, I saw a posting regarding this issue in august, with no solution... How to have the planner use an index in the case of a query like : SELECT * FROM TABLE1 ORDER BY X DESC, Y ASC; (X is a date and Y a varchar) What would that index be? Is there a function I can use, to invert x (the date), so that I can make a query / index set like : CREATE INDEX INDEX1 ON TABLE 1 (INVERT(X), Y ASC); SELECT * FROM TABLE1 ORDER BY INVERT(X) ASC, Y ASC; Wouldn't it be great to have a mySQL, SAPDB-like syntax of the sort : CREATE INDEX INDEX1 ON TABLE 1 (X DESC, Y ASC); Thanks, vincent