If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Accelerating query replies

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-12, 06:03
krontrex krontrex is offline
Registered User
 
Join Date: Sep 2010
Posts: 37
Accelerating query replies

Dear all,
I need to reduce response time for query replies.
A table without foreign keys has been queried.
Queries are simple in the form:
Code:
SELECT col1, col3,col5 FROM mytable WHERE col1='something' AND col2="somethingelse" AND col4>123 AND col9<56 AND col15='some'
First thing is to set indexes:
1) Should I set a separate index on each column appearing in the query or a compound index that includes all columns being queries. In the latter case is the order of appearance of the columns in the index important?
What would be additional measures to accelerate response time?
Thanks
Reply With Quote
  #2 (permalink)  
Old 01-09-12, 06:37
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by krontrex View Post
col2="somethingelse"
That compares the value of column col2 against the value of the column somethingelse
Is that really what you want?
Ddouble quotes denote column names, single quotes denote character literals.

Quote:
In the latter case is the order of appearance of the columns in the index important?
Yes, absolutely.
You might want to go through: http://use-the-index-luke.com/ it has a lot of very good information on how to use indexes in a relational database

Quote:
What would be additional measures to accelerate response time?
EXPLAIN ANALYZE will tell you all you need to know

Last edited by shammat; 01-09-12 at 06:46. Reason: Added link to "use the index luk"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On