Skip site navigation (1) Skip section navigation (2)

Re: RES: select on 1milion register = 6s

From: Decibel! <decibel(at)decibel(dot)org>
To: Ragnar <gnari(at)hive(dot)is>
Cc: Bruno Rodrigues Siqueira <bruno(at)ravnus(dot)com>,pgsql-performance(at)postgresql(dot)org
Subject: Re: RES: select on 1milion register = 6s
Date: 2007-07-29 16:35:37
Message-ID: 20070729163536.GM25704@nasby.net (view raw or flat)
Thread:
Lists: pgsql-performance
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(at)decibel(dot)org
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)

In response to

Responses

pgsql-performance by date

Next:From: Bruno Rodrigues SiqueiraDate: 2007-07-29 16:44:23
Subject: RES: RES: select on 1milion register = 6s
Previous:From: Jay KangDate: 2007-07-29 14:22:30
Subject: Questions on Tags table schema

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group