X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 16D133A3AED for ; Fri, 5 Nov 2004 08:49:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09185-03 for ; Fri, 5 Nov 2004 08:49:08 +0000 (GMT) Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) by svr1.postgresql.org (Postfix) with ESMTP id A6B1F3A3BC1 for ; Fri, 5 Nov 2004 08:49:08 +0000 (GMT) Received: from 222-152-154-34.jetstream.xtra.co.nz ([222.152.154.34] helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1CPzmJ-0006S8-7Y; Fri, 05 Nov 2004 21:49:03 +1300 Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 4680DAD985AF; Fri, 5 Nov 2004 21:49:00 +1300 (NZDT) Subject: Re: Checking = with timestamp field is slow From: Andrew McMillan To: Antony Paul Cc: pgsql-performance@postgresql.org In-Reply-To: <2989532e0411042316566b35f4@mail.gmail.com> References: <2989532e0411042316566b35f4@mail.gmail.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-oaLdnswM0Iu9PCXFLzSs" Date: Fri, 05 Nov 2004 21:48:59 +1300 Message-Id: <1099644539.7326.346.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/91 X-Sequence-Number: 9045 --=-oaLdnswM0Iu9PCXFLzSs Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2004-11-05 at 12:46 +0530, Antony Paul wrote: > Hi all, > I have a table which have more than 200000 records. I need to get > the records which matches like this >=20 > where today::date =3D '2004-11-05'; >=20 > This is the only condition in the query. There is a btree index on the > column today. > Is there any way to optimise it. Hi Antony, I take it your field is called "today" (seems dodgy, but these things happen...). Anywa, have you tried indexing on the truncated value? create index xyz_date on xyz( today::date ); analyze xyz; That's one way. It depends on how many of those 200,000 rows are on each date too, as to whether it will get used by your larger query. Regards, Andrew. ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 When in doubt, tell the truth. -- Mark Twain ------------------------------------------------------------------------- --=-oaLdnswM0Iu9PCXFLzSs Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBBiz57jJA0f48GgBIRAj/MAKC9Pxsc6aRaXomhw/czj3MunJSA+wCgrMV9 LPIveQnVUx/reyz6DenTnzg= =GCx8 -----END PGP SIGNATURE----- --=-oaLdnswM0Iu9PCXFLzSs--