Optimizer generates bad plans.

From: Kris Jurka <jurka(at)ejurka(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Optimizer generates bad plans.
Date: 2002-09-19 22:06:21
Message-ID: 3D8A4A5D.6070701@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While adding schema support to the JDBC Driver, I came across a query
which occasionally generates some spectacularly bad plans. I have
attached the query and explain analyze outputs against today's cvs head
for queries that take between 9 and 845941 msec. In the JDBC Driver I
will specify a reasonable join order using explicit JOINs, but I thought
someone might be interested in a test case for the optimizer.

Kris Jurka

The query tries to determine what foreign keys exists between the
following tables.

create table people (id int4 primary key, name text);
create table policy (id int4 primary key, name text);
create table users (id int4 primary key, people_id int4,
policy_id int4,
CONSTRAINT people FOREIGN KEY (people_id) references people(id),
constraint policy FOREIGN KEY (policy_id) references policy(id));

Attachment Content-Type Size
query.sql text/plain 1.0 KB
badplan.txt text/plain 6.2 KB
goodplan.txt text/plain 6.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-09-19 22:09:06 Re: Optimizer generates bad plans.
Previous Message Bruce Momjian 2002-09-19 22:01:34 Re: GRANT EXECUTE