Re: Please Help: PostgreSQL performance Optimization - Mailing list pgsql-performance

From Andrew Lazarus
Subject Re: Please Help: PostgreSQL performance Optimization
Date
Msg-id 43C6A31F.3010007@pillette.com
Whole thread Raw
In response to Re: Please Help: PostgreSQL performance Optimization  (Jamal Ghaffour <Jamal.Ghaffour@elios-informatique.fr>)
Responses Re: Please Help: PostgreSQL performance Optimization  (Jamal Ghaffour <Jamal.Ghaffour@elios-informatique.fr>)
List pgsql-performance
Jamal Ghaffour wrote:

>>CREATE TABLE cookies (
>>    domain varchar(50) NOT NULL,
>>    path varchar(50) NOT NULL,
>>    name varchar(50) NOT NULL,
>>    principalid varchar(50) NOT NULL,
>>    host text NOT NULL,
>>    value text NOT NULL,
>>    secure bool NOT NULL,
>>    timestamp timestamp with time zone NOT NULL DEFAULT
>>CURRENT_TIMESTAMP+TIME '04:00:00',
>>    PRIMARY KEY  (domain,path,name,principalid)
>>)
[snip]
>>SELECT path, upper(name) AS name, value FROM cookies  WHERE timestamp<CURRENT_TIMESTAMP AND
principalid='192.168.8.219'AND  
>>secure=FALSE AND (domain='ping.icap-elios.com' OR domain='.icap-elios.com')

I think the problem here is that the column order in the index doesn't
match the columns used in the WHERE clause criteria. Try adding an index
on (domain,principalid) or (domain,principalid,timestamp). If these are
your only queries, you can get the same effect by re-ordering the
columns in the table so that this is the column order used by the
primary key and its implicit index.

You should check up on EXPLAIN and EXPLAIN ANALYZE to help you debug
slow queries.

Attachment

pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Throwing unnecessary joins away
Next
From: Ottó Havasvölgyi
Date:
Subject: Re: Throwing unnecessary joins away