Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 695A59FA4B8 for ; Sun, 29 Jul 2007 13:35:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 22938-08 for ; Sun, 29 Jul 2007 13:35:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 1B79F9FA384 for ; Sun, 29 Jul 2007 13:35:40 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id 9D98356447; Sun, 29 Jul 2007 11:35:39 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Sun, 29 Jul 2007 11:35:37 -0500 Date: Sun, 29 Jul 2007 11:35:37 -0500 From: Decibel! To: Ragnar Cc: Bruno Rodrigues Siqueira , pgsql-performance@postgresql.org Subject: Re: RES: select on 1milion register = 6s Message-ID: <20070729163536.GM25704@nasby.net> References: <002001c7d153$944f3c60$e900a8c0@brunolaptop> <1185662176.5778.314.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/QKKmeG/X/bPShih" Content-Disposition: inline In-Reply-To: <1185662176.5778.314.camel@localhost.localdomain> X-Operating-System: FreeBSD 6.1-RELEASE-p10 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.13 (2006-08-11) X-Hashcash: 1:20:070729:gnari@hive.is::fOytpEYVLT6NExap:00003VOi X-Hashcash: 1:20:070729:bruno@ravnus.com::B161IoC58tZVxlv8:01/RQ X-Hashcash: 1:20:070729:pgsql-performance@postgresql.org::Ull5/ZrLeNqDB3qz:00000 0000000000000000000000003SeG X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/412 X-Sequence-Number: 26096 --/QKKmeG/X/bPShih Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 28, 2007 at 10:36:16PM +0000, Ragnar wrote: > On lau, 2007-07-28 at 17:12 -0300, Bruno Rodrigues Siqueira wrote: >=20 > > where > >=20 > > to_char( data_encerramento ,'yyyy-mm')=20 > > between '2006-12' and '2007-01' >=20 > assuming data_encerramento is a date column, try: > WHERE data_encerramento between '2006-12-01' and '2007-01-31' IMO, much better would be: WHERE data_encerramento >=3D '2006-12-01' AND data_encerramento < '2007-02-01' This means you don't have to worry about last day of the month or timestamp precision. In fact, since the field is actually a timestamp, the between posted above won't work correctly. --=20 Decibel!, aka Jim Nasby decibel@decibel.org EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) --/QKKmeG/X/bPShih Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (FreeBSD) iD8DBQFGrMHYdO30qud8SkgRAgMIAJ0atZCkaGT+a3zd4foO0d7x0TqGJACfc5iq pwP9LDIvDGjzuLNWirlXLiY= =+mjD -----END PGP SIGNATURE----- --/QKKmeG/X/bPShih--