Niclas Gustafsson <Niclas.Gustafsson@codesense.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