slow query execution

Поиск
Список
Период
Сортировка
От Trigve Siver
Тема slow query execution
Дата
Msg-id 543741.9839.qm@web52709.mail.re2.yahoo.com
обсуждение исходный текст
Ответы Re: slow query execution  (Andrew Sullivan <ajs@crankycanuck.ca>)
Список pgsql-sql
Hi all,

This query executes very slow:

select (select count(*) from customer where id <= a.id) as row, id, from customer as a order by id;

Where customer has id column and others and has also index on id column. The table has about 10.000+ records. When used
with"explain", it gives me this output:
 
                                       QUERY PLAN

-----------------------------------------------------------------------------------------Sort
(cost=6513774.23..6513801.37rows=10855 width=14)  Sort Key: id  ->  Seq Scan on customer a  (cost=0.00..6513046.62
rows=10855width=14)        SubPlan          ->  Aggregate  (cost=599.94..599.95 rows=1 width=0)                ->
BitmapHeap Scan on customer  (cost=28.66..590.89 rows=361 width=0)                      Recheck Cond: (id <= $0)
             ->  Bitmap Index Scan on iid  (cost=0.00..28.66 rows=361 width=0)                            Index Cond:
(id<= $0)
 
(9 riadkov)


So is there any solution to speed up this query? Or can I get the same result but with some other query?

thanks

Trigve




      
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  


В списке pgsql-sql по дате отправления:

Предыдущее
От: Gerardo Herzig
Дата:
Сообщение: logging amount rows retrieved?
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: slow query execution