Re: Slow query - Mailing list pgsql-sql

From Tomasz Myrta
Subject Re: Slow query
Date
Msg-id 3E2FFF91.7020700@klaster.net
Whole thread Raw
In response to Slow query  (Ricardo Javier Aranibar León<ricardo_jal@hotmail.com>)
List pgsql-sql
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




pgsql-sql by date:

Previous
From: Ricardo Javier Aranibar León
Date:
Subject: Slow query
Next
From: Tom Lane
Date:
Subject: Re: calling function from rule