Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 82AF34767BA for ; Thu, 23 Jan 2003 10:31:36 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 74D66476FFC for ; Thu, 23 Jan 2003 10:20:50 -0500 (EST) Received: from klaster.net (ph213.krakow.cvx.ppp.tpnet.pl [217.99.208.213]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 3FF352B87C for ; Thu, 23 Jan 2003 15:34:29 +0100 (CET) Message-ID: <3E2FFF91.7020700@klaster.net> Date: Thu, 23 Jan 2003 15:43:29 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 Cc: pgsql-sql@postgresql.org Subject: Re: Slow query References: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/358 X-Sequence-Number: 11223 Ricardo Javier Aranibar León wrote: > 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) I'm not sure if there is much to help. You have a lots of rows in result - 23k rows and 12k rows. The problem is in output, not in query or indexing. Do you really use such queries? Anyway, did you vaccum analyze before testing? Regards, Tomasz Myrta