From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Niclas Gustafsson <Niclas(dot)Gustafsson(at)codesense(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Indices for both where and order by. |
Date: | 2002-05-23 20:21:56 |
Message-ID: | 23445.1022185316@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-general |
Niclas Gustafsson <Niclas(dot)Gustafsson(at)codesense(dot)com> writes:
> Select * from hs where tcode = 'XXZZ' order by timestamp
> An idea was to create an Index on both tcode and timestamp, like this
> Create index hs_tcode_timestamp_idx on hs (tcode, timestamp)
> Am I completely wrong here, or could the planner not use it for both the
> where and the sorting?
You'd have to write
Select * from hs where tcode = 'XXZZ' order by tcode, timestamp
to get the planner to realize that the index ordering is what's wanted.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Kowalczyk | 2002-05-24 03:20:27 | Forgot admin pw on initialization/install RH 7.3/PGSQL7.2 |
Previous Message | Niclas Gustafsson | 2002-05-23 19:39:38 | Indices for both where and order by. |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-05-23 20:46:08 | Re: Just PR (was: Stability, PR) |
Previous Message | Jan Wieck | 2002-05-23 20:17:12 | Re: Stored Procedure Problem |