Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CFA4D47616E for ; Thu, 23 Jan 2003 09:16:16 -0500 (EST) Received: from hotmail.com (f175.law9.hotmail.com [64.4.9.175]) by postgresql.org (Postfix) with ESMTP id 71B02476070 for ; Thu, 23 Jan 2003 09:16:14 -0500 (EST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 23 Jan 2003 06:16:18 -0800 Received: from 64.7.127.220 by lw9fd.law9.hotmail.msn.com with HTTP; Thu, 23 Jan 2003 14:16:17 GMT X-Originating-IP: [64.7.127.220] From: =?iso-8859-1?B?UmljYXJkbyBKYXZpZXIgQXJhbmliYXIgTGXzbg==?= To: pgsql-sql@postgresql.org Cc: ricardo_jal@linuxmail.org Subject: Slow query Date: Thu, 23 Jan 2003 14:16:17 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Message-ID: X-OriginalArrivalTime: 23 Jan 2003 14:16:18.0191 (UTC) FILETIME=[FF0B89F0:01C2C2E9] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/357 X-Sequence-Number: 11222 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 _________________________________________________________________