CREATE INDEX with order clause

From: "Daniel Caune" <daniel(dot)caune(at)ubisoft(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: CREATE INDEX with order clause
Date: 2006-02-01 15:46:03
Message-ID: 1E293D3FF63A3740B10AD5AAD88535D20171B758@UBIMAIL1.ubisoft.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I would like to create an index on a table, specifying an order clause
for one of the columns.

CREATE INDEX IDX_GSLOG_EVENT_PLAYER_EVENT_TIME_DESC

ON GSLOG_EVENT(PLAYER_USERNAME,

EVENT_NAME,

EVENT_DATE_CREATED DESC);

which is not a valid, as the order clause DESC is not supported. Such
as index would improve performance of query like:

SELECT GAME_CLIENT_VERSION

FROM GSLOG_EVENT

WHERE PLAYER_USERNAME = ?

AND EVENT_NAME = ?

AND EVENT_DATE_CREATED < ?

ORDER BY EVENT_DATE_CREATED DESC

LIMIT 1

Actually, I'm not sure that is useful; perhaps PostgreSQL handles pretty
well such query using an index such as:

CREATE INDEX IDX_GSLOG_EVENT_PLAYER_EVENT_TIME_DESC

ON GSLOG_EVENT(PLAYER_USERNAME,

EVENT_NAME,

EVENT_DATE_CREATED);

Any idea?

--

Daniel CAUNE

Ubisoft Online Technology

(514) 4090 2040 ext. 5418

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-02-01 16:16:07 Re: CREATE INDEX with order clause
Previous Message codeWarrior 2006-02-01 15:45:18 Re: executing dynamic commands