X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id DBB4011F6645 for ; Tue, 11 Apr 2006 10:13:30 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id WjnMpgtUVlq5 for ; Tue, 11 Apr 2006 10:13:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) by postgresql.org (Postfix) with ESMTP id 3987B11F65C6 for ; Tue, 11 Apr 2006 10:13:23 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i32so1116956wra for ; Tue, 11 Apr 2006 06:13:24 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SXCAPOvu6wtc/lV2WFgeyTfb0OsMjCyPZ1jJakDZUqWm4qvYhTKwoQZU5MSPzHFAEpV1QSS1v+QXpjuIljt1dGoPknmsS1R+7uuA3I5fCpgzxRZzwUIy7IF+w27nCtC02zUQCoQXI2Tj1RkHkIWQm4DlHzWz80zdNSYoFzHiV/A= Received: by 10.65.97.20 with SMTP id z20mr4980704qbl; Tue, 11 Apr 2006 06:13:24 -0700 (PDT) Received: by 10.65.137.8 with HTTP; Tue, 11 Apr 2006 06:13:24 -0700 (PDT) Message-ID: Date: Tue, 11 Apr 2006 09:13:24 -0400 From: "Merlin Moncure" To: "soni de" Subject: Re: Takes too long to fetch the data from database Cc: pgsql-performance@postgresql.org In-Reply-To: <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> X-Archive-Number: 200604/233 X-Sequence-Number: 18317 > pdb=3D# explain analyze SELECT sdate, stime, rbts from lan WHERE ( > > ( bname =3D 'pluto' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate > > >=3D '2004-07-21' ) AND ( sdate <=3D '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=3D# explain analyze SELECT ALL sdate, stime, rbts from lan WHERE ( ( > bname =3D 'neptune' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate = >=3D > '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sdate, stim= e ; ditto above. Generally, the closer the fields in the where clause are matched by the index, the it will speed up your query. Merlin