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/
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers