From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Miguel <mmiranda(at)123(dot)com(dot)sv> |
Cc: | Jaime Casanova <systemguards(at)gmail(dot)com>, "Javier Aquino H(dot)" <JAquino(at)lexuseditores(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: consulta se demora mucho mas que antes |
Date: | 2006-03-31 17:43:56 |
Message-ID: | 20060331174355.GA14204@surnet.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
> Invertir el orden no ayudo mucho:
>
> radius=# explain
> radius-# select 'quemados',sum(acctsessiontime)/60 as minutos,
> sum(roundedsessiontime)/60 as redondeados
> radius-# from stopacct a inner join pines b on (a.username = b.pin)
> radius-# where h323disconnecttime::date = '2006-03-29'::date
> radius-# and h323callorigin = 'originate'
> radius-# and idproducto in (11,40,41);
> QUERY PLAN
> ----------------------------------------------------------------------------------------------------------------------------
> Aggregate (cost=393646.90..393646.91 rows=1 width=16)
> -> Nested Loop (cost=0.00..393639.84 rows=1411 width=16)
> -> Seq Scan on stopacct a (cost=0.00..382461.38 rows=1853
> width=31)
> Filter: (((h323disconnecttime)::date =
> '2006-03-29'::date) AND ((h323callorigin)::text = 'originate'::text))
> -> Index Scan using pines_pkey on pines b (cost=0.00..6.02
> rows=1 width=13)
> Index Cond: (("outer".username)::text = (b.pin)::text)
> Filter: ((idproducto = 11) OR (idproducto = 40) OR
> (idproducto = 41))
> (7 rows)
Me da la impresion de que el cast ese a date no ayuda mucho. Que pasa
si usas algo como
WHERE h323disconnecttime between
'2006-03-29'::timestamptz and '2006-03-30'::timestamptz
and h323callorigin = 'originate'
(obviamente cambia timestamptz a timestamp si tu campo no tiene TZ, lo
cual seria un error)
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2006-03-31 17:45:52 | Re: Listar columnas de una tabla. |
Previous Message | Pablo Braulio | 2006-03-31 17:43:09 | Listar columnas de una tabla. |