Strange behavior when using "limit" with example tables.

Поиск
Список
Период
Сортировка
От domingo@dad-it.com (Domingo Alvarez Duarte)
Тема Strange behavior when using "limit" with example tables.
Дата
Msg-id 70a76315.0202260211.1d834022@posting.google.com
обсуждение исходный текст
Список pgsql-hackers
In the previous post I didn't provide the tables to make the test,
here I put the tables available at:

http://unolotiene.com/test_tables.sql.bz2

As well I redid the test with only two tables and the problem is still
there.

Using "limit" makes postgresql eats all cpu for a while.

Is that a bug or a mistake from my part ?

------------------------------------------------------------------------------
-- Without limit
explain select ca.*, cmm.name 
from car_adverts as ca, car_models as cmm 
where ca.maker=cmm.id;

NOTICE:  QUERY PLAN:

Merge Join  (cost=2498.96..2773.64 rows=162540 width=192) ->  Index Scan using car_models_pkey on car_models cmm 
(cost=0.00..59.00 rows=1000 width=16) ->  Sort  (cost=2498.96..2498.96 rows=16254 width=176)
--------------------------------------------------------------------------------
-- Now with limit
explain select ca.*, cmm.name 
from car_adverts as ca, car_models as cmm 
where ca.maker=cmm.id limit 10;

NOTICE:  QUERY PLAN:

Limit  (cost=0.00..32.53 rows=10 width=192) ->  Nested Loop  (cost=0.00..528760.54 rows=162540 width=192)       ->  Seq
Scanon car_adverts ca  (cost=0.00..505.54 rows=16254
 
width=176)       ->  Seq Scan on car_models cmm  (cost=0.00..20.00 rows=1000
width=16)       ->  Seq Scan on car_adverts ca  (cost=0.00..505.54
rows=16254 width=176)


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

Предыдущее
От: "Adam"
Дата:
Сообщение: Re: setting up a trace through extended stored procedures
Следующее
От: domingo@dad-it.com (Domingo Alvarez Duarte)
Дата:
Сообщение: Misbehavior of the query optimizer when using limit.