Strange behavior when using "limit" with example tables.

From: domingo(at)dad-it(dot)com (Domingo Alvarez Duarte)
To: pgsql-hackers(at)postgresql(dot)org
Subject: Strange behavior when using "limit" with example tables.
Date: 2002-02-26 10:11:25
Message-ID: 70a76315.0202260211.1d834022@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Scan on 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)

Browse pgsql-hackers by date

  From Date Subject
Next Message John Gray 2002-02-26 10:32:17 Refactoring of command.c
Previous Message Domingo Alvarez Duarte 2002-02-26 08:10:03 Misbehavior of the query optimizer when using limit.