Optimizer picks an ineffient plan

Поиск
Список
Период
Сортировка
От Bupp Phillips
Тема Optimizer picks an ineffient plan
Дата
Msg-id bj0v98$1f1q$1@news.hub.org
обсуждение исходный текст
Ответы Re: Optimizer picks an ineffient plan  (Greg Stark <gsstark@mit.edu>)
Список pgsql-general
I have a customer table that has the field CUSTOMER_ID as the primary key
(cust_pkkey), the table has 102,834 records in it.


The following select statement works fine:

select * from customer order by customer_id;
QUERY PLAN:
Index Scan using cust_pkkey on customer  (cost=0.00..5175.17 rows=102834
width=724)
Total runtime: 5999.47 msec

but...

select * from customer order by customer_id, first_name;
QUERY PLAN:
Sort(cost=142028.25..142028.25 rows=102834 width=724)
 -> Seq Scan on customer (cost=0.00..4617.34 rows=102834 width=724)
Total runtime: 19999.81 msec


It seems that the optimizer should be able to detect (in this instance at
least) that the first order by field is a primary key and should not
consider the other fields because it's pointless... the resultset will be in
<primary key> order.

NOTE:  I'm testing this on Postgresql 7.2 for Windows, so this my have
already been dealt with.


Thanks and keep up the great work!!



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

Предыдущее
От: "Kuldeep Tanna"
Дата:
Сообщение: Crosstab function Problem
Следующее
От: Alessandro GARDICH
Дата:
Сообщение: automatic update