Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread ORDER BY Clause Using DESC Index
Thu, Jul 22 2010 5:18 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

Tim

Using EDB 2.03b15.  I have a table which looks something like this.

CREATE TABLE "ClientEpisode"
(
"ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 281, INCREMENT BY 1) NOT NULL,
"ClientID" INTEGER NOT NULL,
"EpisodeDate" TIMESTAMP NOT NULL,
<more stuff>
CONSTRAINT "cePrimaryKey" PRIMARY KEY ("ID")
)

CREATE INDEX "ceClientDateIND" ON "ClientEpisode" ("ClientID", "EpisodeDate" DESC)
CREATE INDEX "ceClientIND" ON "ClientEpisode" ("ClientID", "EpisodeDate")


The queries below both produce the result set in DESCENDING EpisodeDate order.
SELECT * FROM ClientEpisode ORDER BY ClientID, EpisodeDate ASC
SELECT * FROM ClientEpisode ORDER BY ClientID, EpisodeDate DESC

The execution plan for both queries stated "The result set was ordered using the index ceClientDateIND"

Richard Harding
Fri, Jul 23 2010 10:07 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< The execution plan for both queries stated "The result set was ordered
using the index ceClientDateIND" >>

Yep, it's checking for DESC against ASC indexes, but not ASC against DESC
indexes.  It's now fixed for B18, which I'm doing over the weekend.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image