From: | Fernando Romo <pop(at)cofradia(dot)org> |
---|---|
To: | Jaime Casanova <systemguards(at)yahoo(dot)com> |
Cc: | Luz Lopez <viaris(at)hotmail(dot)com>, alvherre(at)dcc(dot)uchile(dot)cl, pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: acelerar la ejecucion de consultas |
Date: | 2004-11-12 16:54:13 |
Message-ID: | 4194EAB5.1030403@cofradia.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
No uses funciones agregadas. lee este artículo que escríbi hace un rato:
http://cofradia.org/modules.php?name=News&file=article&sid=4971
Saludos.... El Pop
Jaime Casanova wrote:
> --- 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
>
>---------------------------(end of broadcast)---------------------------
>TIP 8: explain analyze es tu amigo
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2004-11-12 17:09:40 | Re: acelerar la ejecucion de consultas |
Previous Message | Jaime Casanova | 2004-11-12 16:41:04 | Re: acelerar la ejecucion de consultas |