pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Decibel! <decibel@decibel.org>
To: Ragnar <gnari@hive.is>
Cc: Bruno Rodrigues Siqueira <bruno@ravnus.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: RES: select on 1milion register = 6s
Date: Sun, 29 Jul 2007 11:35:37 -0500
Message-ID: <20070729163536.GM25704@nasby.net> (raw)
In-Reply-To: <1185662176.5778.314.camel@localhost.localdomain>
References: <002001c7d153$944f3c60$e900a8c0@brunolaptop>
	<1185662176.5778.314.camel@localhost.localdomain>

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:
> 
> > where
> > 
> > to_char( data_encerramento ,'yyyy-mm') 
> > between   '2006-12' and  '2007-01'
> 
> 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 >= '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.
-- 
Decibel!, aka Jim Nasby                        decibel@decibel.org
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)

view thread (5+ messages)

Message-ID: <20070729163536.GM25704@nasby.net>
Permalink:  ../20070729163536.GM25704@nasby.net/
Also on:    postgresql.org/message-id/20070729163536.GM25704@nasby.net

 · 

reply

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: decibel@decibel.org, gnari@hive.is, bruno@ravnus.com
  Subject: Re: RES: select on 1milion register = 6s
  In-Reply-To: <20070729163536.GM25704@nasby.net>

* 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