From: Merlin Moncure <mmoncure@gmail.com>
To: soni de <soni.de@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Takes too long to fetch the data from database
Date: Tue, 11 Apr 2006 09:13:24 -0400
Message-ID: <b42b73150604110613h2c63ea61oec8035c8e2f4ed98@mail.gmail.com> (raw)
In-Reply-To: <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com>
References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com>
<b42b73150604100845w553dcee6kde20e4b82770aab0@mail.gmail.com>
<9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mmoncure@gmail.com, soni.de@gmail.com
Subject: Re: Takes too long to fetch the data from database
In-Reply-To: <b42b73150604110613h2c63ea61oec8035c8e2f4ed98@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox