Re: Indice para columna date

From: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Pablo Marrero <pablo(dot)marrero(at)bancaqm(dot)com(dot)uy>
Cc: AyudaPostgres <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Indice para columna date
Date: 2004-10-21 13:40:09
Message-ID: 200410211040.09865.martin@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

El Jue 21 Oct 2004 09:55, escribió:
> ahi va el explain
>
> EXPLAIN ANALYZE select count(*) as cantidad from cupones_usados where
> fecha_sorteo>='2004-07-20'::date and fecha_sorteo<='2004-10-20'::date;
> QUERY PLAN
> ---------------------------------------------------------------------------
>---------------------------------------------------- Aggregate
> (cost=24365.57..24365.57 rows=1 width=0) (actual
> time=3943.420..3943.421 rows=1 loops=1)
> -> Seq Scan on cupones_usados (cost=0.00..22636.80 rows=691507
> width=0) (actual time=0.076..2510.919 rows=729794 loops=1)
> Filter: ((fecha_sorteo >= '2004-07-20'::date) AND (fecha_sorteo
> <= '2004-10-20'::date))
> Total runtime: 3943.564 ms
> (4 rows)

Tenes algo raro en la configuracion que no esta dejando usar el indice:

lismarch=> CREATE INDEX prueba_time ON archivo (time_arch);
CREATE INDEX
lismarch=> explain analyze select count(*) from archivo where time_arch >=
'10/2/2004'
lismarch-> ;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=785.66..785.66 rows=1 width=0) (actual time=485.137..485.140
rows=1 loops=1)
-> Index Scan using prueba_time on archivo (cost=0.00..784.87 rows=313
width=0) (actual time=0.194..398.390 rows=1955 loops=1)
Index Cond: (time_arch >= '10/02/2004 00:00:00 ART'::timestamp with
time zone)
Total runtime: 488.306 ms
(4 filas)

Y eso que apenas hay 1955 filas.

Fijate las siguientes variables que valores tienen:

enable_seqscan
enable_indexscan
stats_start_collector

Evidentemente algo en la configuracion esta haciendo que el PLANNER no use el
indice.

--
10:25:01 up 39 days, 43 min, 3 users, load average: 0.94, 1.36, 1.42
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Martín Marqués 2004-10-21 14:08:49 Re: Indice para columna date
Previous Message Pablo Marrero 2004-10-21 12:55:09 Re: Indice para columna date