how to leverage index for order by

From: sreeaurovindh viswanathan <sreeaurovindh(at)gmail(dot)com>
To: PGSQL-Novice <pgsql-novice(at)postgresql(dot)org>
Subject: how to leverage index for order by
Date: 2012-03-23 03:29:41
Message-ID: CAC4BLaLMSisbOZ+YKV7AX=dtexO=3ia_1XmZfU=gCwXHt=Oc3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I have about 140 million columns and would like to sort multiple
columns.(This is in a way a one time process).But I would like to get
the results atleast within a day time frame.
For example

I have a table which has five columns all are numbers except one column.

id bigserial
qid numeric
kid numeric
dId numeric
uId text.

I am trying to do something like this.

select * from schema.table1 order by qid desc,kid asc,dId desc

Please explain on how do create and leverage that index for sorting.

I tried in the following manner to come up with an index but my above
query did not use this index

create index myIndex on table1(qid asc)

thanks
Sree aurovindh V

Thanks

Browse pgsql-novice by date

  From Date Subject
Next Message Cheng 2012-03-23 16:26:14 Define a function that accepts query result as a parameter
Previous Message sreeaurovindh viswanathan 2012-03-22 15:43:35 Re: Regarding Copy in postgresql