From: | Leopoldo Rojas Rocha <polo(dot)rojas(at)gmail(dot)com> |
---|---|
To: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | problemas con indice |
Date: | 2005-07-08 23:33:32 |
Message-ID: | 2e79c3c405070816336e93de71@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola lista...cual seria su opinion para optimizar el query
Tengo un problema al generar un Select donde el tiempo de espera varia
entre los 11 y 14 sec dependiendo (la cantidad de datos en la tabla
son aprox > 350,000) :
Select ot,cvinv,sum(salc) as tk from kardex1
where ot <> ''::varchar(10)
Group By ot,cvinv
Solo sumo el campo salc agrupando los campos ot (orden) ,cvinv (clave
inv.),genere 2 tipo de indices usando combinaciones tipos de indices
(btree,hash) y ninguno me resulto
CREATE INDEX idx_ot1
ON kardex1
USING btree
(ot);
CREATE INDEX idx_ot1
ON kardex1
USING btree
(ot,cvinv);
El Explain analyze me deja los siguientes datos
"GroupAggregate (cost=69465.68..72926.98 rows=39801 width=43) (actual
time=9619.787..11635.753 rows=278522 loops=1)"
" -> Sort (cost=69465.68..70306.13 rows=336179 width=43) (actual
time=9619.731..10190.379 rows=296165 loops=1)"
" Sort Key: ot, cvinv"
" -> Seq Scan on kardex1 (cost=0.00..14696.35 rows=336179
width=43) (actual time=0.061..992.690 rows=296165 loops=1)"
" Filter: ((ot)::text <> ''::text)"
"Total runtime: 11946.628 ms"
Por ultimo, mi tabla es :
CREATE TABLE kardex1
(
almacen varchar(1),
cvinv varchar(10),
tmovi varchar(30),
fecha date,
entc numeric(14,5),
entp numeric(12,3),
salc numeric(14,5),
salp numeric(12,3),
peri1 numeric(6),
fuente varchar(10),
entsal varchar(1),
nument varchar(10),
provee numeric(4),
fact1 varchar(10),
ocomp numeric(6),
ot varchar(10),
pt varchar(10),
cliente varchar(10),
salio_de varchar(10),
do_partida numeric(3),
us_user varchar(10),
lastmodi date,
hora varchar(8),
lote varchar(14)
)
WITHOUT OIDS;
Agradesco sus comentarios.
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2005-07-08 23:47:08 | Re: problemas con indice |
Previous Message | Leonardo Boet Sánchez | 2005-07-08 21:24:26 | RE: [pgsql-es-ayuda] solicitud información |