dbTalk Databases Forums  

Multicolumn Indexes

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Multicolumn Indexes in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Yagel
 
Posts: n/a

Default Multicolumn Indexes - 10-15-2004 , 11:36 AM






I have a situtation where a particular table includes a timestamp column and
a id column. The query I am working with right now filters based on
timestamp and orders based on ID.

I have not found enough information about how multicolumn indexes actually
work to determine if one will help me in this case, but I think that it
might.

Right now the index that I have on timestamp is not used because the Primary
Key(ID) index is chosen for ordering. If I place a multicolumn index on
(timestamp, id) will that index be able to filter the timestamp and still be
used for returning the ordered IDs?

Also is there any documentation out there that provides more details about
the specific behavior of multi column indexes in Postgresql.

Thanks,
Thomas


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: Multicolumn Indexes - 10-15-2004 , 12:57 PM






"Thomas Yagel" <tyagel (AT) yahoo (DOT) com> writes:
Quote:
Right now the index that I have on timestamp is not used because the Primary
Key(ID) index is chosen for ordering. If I place a multicolumn index on
(timestamp, id) will that index be able to filter the timestamp and still be
used for returning the ordered IDs?
You'd need to do that and also say "ORDER BY timestamp, id" not just
"ORDER BY id".

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.