|
|||||||||||
|
RES: RES: [PERFORM] select on 1milion register = 6s
From: Bruno Rodrigues Siqueira <bruno(at)ravnus.com>
Date: Sun Jul 29 2007 - 12:44:23 EDT
EXPLAIN
to_char(data_encerramento,'mm/yyyy') as opcoes_mes,
to_char(data_encerramento,'yyyy-mm') as ordem from detalhamento_bas
where
data_encerramento = '01/12/2006'
GROUP BY opcoes_mes, ordem
QUERY PLAN
-> Index Scan using detalhamento_bas_idx3005 on detalhamento_bas (cost=0.00..60.67 rows=105 width=8) (actual time=4.576..4.576 rows=0 loops=1)
Index Cond: (data_encerramento = '2006-12-01
00:00:00'::timestamp without time zone)
//////////////////////////////////////////////////////////////////////////// EXPLAIN
to_char(data_encerramento,'mm/yyyy') as opcoes_mes,
to_char(data_encerramento,'yyyy-mm') as ordem from detalhamento_bas
where
data_encerramento >= '01/12/2006' and
GROUP BY opcoes_mes, ordem
QUERY PLAN
-> Seq Scan on detalhamento_bas (cost=0.00..217945.41 rows=2335358 width=8) (actual time=0.041..8535.792 rows=2335819 loops=1) Filter: ((data_encerramento >= '2006-12-01 00:00:00'::timestamp without time zone) AND (data_encerramento < '2007-02-01 00:00:00'::timestamp without time zone)) Total runtime: 10079.256 ms Strange!!! Why does the index not works? All my querys doesn't work with range dates.... I don't know what to do... Please, help! Bruno
-----Mensagem original-----
On Sat, Jul 28, 2007 at 10:36:16PM +0000, Ragnar wrote:
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) ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.orgReceived on Sun Jul 29 12:47:10 2007 This archive was generated by hypermail 2.1.8 : Thu Aug 09 2007 - 19:46:50 EDT |
||||||||||
|
|||||||||||