Re: Takes too long to fetch the data from database - Mailing list pgsql-performance

From Merlin Moncure
Subject Re: Takes too long to fetch the data from database
Date
Msg-id b42b73150604110613h2c63ea61oec8035c8e2f4ed98@mail.gmail.com
Whole thread Raw
In response to Takes too long to fetch the data from database  ("soni de" <soni.de@gmail.com>)
Responses Re: Takes too long to fetch the data from database  ("soni de" <soni.de@gmail.com>)
List pgsql-performance
> pdb=# explain analyze SELECT sdate, stime, rbts from lan WHERE (
>
>  ( bname = 'pluto' ) AND ( cno = 17 ) AND ( pno = 1 ) AND ( ( sdate
>
>  >= '2004-07-21' ) AND ( sdate <= '2004-07-21' ) )  )  ORDER BY sdate, stime
> ;

this query would benefit from an index on
pluto, cno, pno, sdate

create index Ian_idx on Ian(bname, cno, pno, sdate);


> pdb=# explain analyze SELECT ALL sdate, stime, rbts from lan WHERE (  (
> bname = 'neptune' ) AND ( cno = 17 ) AND ( pno = 1 ) AND ( ( sdate >=
> '2004-07-21' ) AND ( sdate <= '2004-07-21' ) )  )  ORDER BY sdate, stime ;

ditto above.  Generally, the closer the fields in the where clause are
matched by the index, the it will speed up your query.

Merlin

pgsql-performance by date:

Previous
From: "Jesper Krogh"
Date:
Subject: Re: Restore performance?
Next
From: "Merlin Moncure"
Date:
Subject: Re: Stored Procedure Performance