Re: planner or statistical bug on 8.5 - Mailing list pgsql-hackers

From Matteo Beccati
Subject Re: planner or statistical bug on 8.5
Date
Msg-id 4B4C2CC6.4060902@beccati.com
Whole thread Raw
In response to planner or statistical bug on 8.5  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: planner or statistical bug on 8.5
List pgsql-hackers
Il 12/01/2010 08:55, Pavel Stehule ha scritto:
> I checked query and I was surprised with very strange plan:
>
> postgres=# explain select  a, b from a,b,c;
>                                QUERY PLAN
> -----------------------------------------------------------------------
>   Nested Loop  (cost=0.00..276595350.00 rows=13824000000 width=8)
>     ->   Nested Loop  (cost=0.00..115292.00 rows=5760000 width=8)
>           ->   Seq Scan on a  (cost=0.00..34.00 rows=2400 width=4)
>           ->   Materialize  (cost=0.00..82.00 rows=2400 width=4)
>                 ->   Seq Scan on b  (cost=0.00..34.00 rows=2400 width=4)
>     ->   Materialize  (cost=0.00..82.00 rows=2400 width=0)
>           ->   Seq Scan on c  (cost=0.00..34.00 rows=2400 width=0)
> (7 rows)

It doesn't surprise me. Tables are empty, thus get a default non-0 row 
estimate, which happens to be 2400:

test=# create table a (a int);
CREATE TABLE
test=# ANALYZE a;
ANALYZE
test=# EXPLAIN SELECT * from a;                     QUERY PLAN
----------------------------------------------------- Seq Scan on a  (cost=0.00..14.80 rows=2400 width=4)
(1 row)


That said, 2400^3 (cross join of 3 tables) == 13824000000


Cheers
-- 
Matteo Beccati

Development & Consulting - http://www.beccati.com/


pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: damage control mode
Next
From: Greg Smith
Date:
Subject: Re: Streaming replication status