From: | Jaime Casanova <systemguards(at)yahoo(dot)com> |
---|---|
To: | Luz Lopez <viaris(at)hotmail(dot)com>, alvherre(at)dcc(dot)uchile(dot)cl |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: acelerar la ejecucion de consultas |
Date: | 2004-11-12 16:41:04 |
Message-ID: | 20041112164104.85907.qmail@web50005.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
--- Luz Lopez <viaris(at)hotmail(dot)com> escribió:
> Hola,
>
> La conculta exacta fue:
>
> EXPLAIN ANALYZE select EXTRACT(MONTH FROM M.fecha)
> as ho,count(*) as tot
> from correo M where EXTRACT(YEAR FROM
> M.fecha)='2004' group by EXTRACT(MONTH
> FROM M.fecha);
>
> Mi indice lo tengo asi:
>
> Index "web_sms1_fecha"
> Column | Type
> --------+------
> fecha | date
> btree
>
> Y el resultado del Explain es:
>
> Aggregate (cost=122439.31..122558.36 rows=2381
> width=4) (actual
> time=64626.46..76021.93 rows=11 loops=1)
> -> Group (cost=122439.31..122498.84 rows=23809
> width=4) (actual
> time=63951.10..73332.27 rows=4177209 loops=1)
> -> Sort (cost=122439.31..122439.31
> rows=23809 width=4) (actual
> time=63951.09..67240.94 rows=4177209 loops=1)
> -> Seq Scan on web_sms m
> (cost=0.00..120708.48 rows=23809
> width=4) (actual time=0.30..55077.31 rows=4177209
> loops=1)
> Total runtime: 76069.22 msec
>
> Gracias.
>
Hola hace no mucho te sugeri crear un indice asi:
create index tuIndice on correo (extract(year from
fecha));
sin embargo parece que la sintaxis es incorrecta mejor
hazlo de esta forma:
create index tuIndice on correo (date_part('year',
fecha));
y me parece que quiza tambien te puede ayudar crear un
indice:
create index tuIndice2 on correo (date_part('month',
fecha));
cambia el select para usar date_part en vez de
extract:
select date_part('MONTH', M.fecha) as ho,
count(*) as tot
from correo M
where date_part('YEAR', M.fecha) = '2004'
group by date_part('MONTH', M.fecha);
Atentamente,
Jaime Casanova
_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Fernando Romo | 2004-11-12 16:54:13 | Re: acelerar la ejecucion de consultas |
Previous Message | Luz Lopez | 2004-11-12 16:00:59 | Re: acelerar la ejecucion de consultas |