Slow query

From: Ricardo Javier Aranibar León <ricardo_jal(at)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: ricardo_jal(at)linuxmail(dot)org
Subject: Slow query
Date: 2003-01-23 14:16:17
Message-ID: F175ILXS1eRw9QLMI1700017d12@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi List,

I need your help, I don't know what happend with my queries when I use this
table "simon".When I like display the result the query is very slow and take
five minutes or more.
The number of registers in simon is:2421580
and the other table "llamada" the number of registers is :1779741 but the
time of my query is faster that when i run the query but using my table
simon
The struct of my table "simon" is:

Table "simon"
Attribute | Type | Modifier
-----------+-------------+-------------------------------------------------
num | integer | not null default nextval('simon_num_seq'::text)
ip | varchar(16) |
fecha | date |
hora | time |
tras | smallint |
reci | smallint |
perd | smallint |
min | float4 |
avg | float4 |
max | float4 |
Indices:
avg_si,fecha_si,hora_si,ip_si,max_si,min_si,perd_si,reci_si,simon_hora,
simon_pkey,tras_si

I run Explain and this is the result:
EXPLAIN SELECT * from simon where fecha='20030122' order by hora desc;
NOTICE: QUERY PLAN:
Sort (cost=57700.73..57700.73 rows=23682 width=46)
-> Seq Scan on simon (cost=0.00..55591.05 rows=23682 width=46)

and when I run explain for another table this is te result:
EXPLAIN SELECT * from llamada where fecha='20030122' order by hora desc;
NOTICE: QUERY PLAN:
Sort (cost=41102.70..41102.70 rows=12413 width=82)
-> Index Scan using fecha_lla on llamada (cost=0.00..39944.95 rows=12413
width=82)

This is the sintax when i created my index:
CREATE INDEX fecha_si ON simon USING btree(fecha);

If somebody can help me or tell me why my queries using the table simon are
slow, I will thankfull

Regards,
Ricardo

PD:Sorry for my grammar Enghish

_________________________________________________________________

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-01-23 14:43:29 Re: Slow query
Previous Message Tambet Matiisen 2003-01-23 10:51:35 calling function from rule