Skip site navigation (1) Skip section navigation (2)

Optimizer showing wrong rows in plan

From: Tadipathri Raghu <traghu(dot)dba(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Optimizer showing wrong rows in plan
Date: 2010-03-28 06:51:04
Message-ID: 645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
Hi All,

Example on optimizer
===============
postgres=# create table test(id int);
CREATE TABLE
postgres=# insert into test VALUES (1);
INSERT 0 1
postgres=# select * from test;
 id
----
  1
(1 row)
postgres=# explain select * from test;
                       QUERY PLAN
--------------------------------------------------------
 Seq Scan on test  (cost=0.00..34.00 *rows=2400* width=4)
(1 row)
In the above, example the optimizer is retreiving those many rows where
there is only one row in that table. If i analyze am geting one row.

postgres=# ANALYZE test;
ANALYZE
postgres=# explain select * from test;
                     QUERY PLAN
----------------------------------------------------
 Seq Scan on test  (cost=0.00..1.01 *rows=1* width=4)
(1 row)

My question here is, what it retreiving as rows when there is no such. One
more thing, if i wont do analyze and run the explain plan for three or more
times, then catalogs getting updated automatically and resulting the correct
row as 1.

Q2. Does explain , will update the catalogs automatically.

Regards
Raghavendra

Responses

pgsql-performance by date

Next:From: Szymon GuzDate: 2010-03-28 07:02:14
Subject: Re: Optimizer showing wrong rows in plan
Previous:From: Richard YenDate: 2010-03-28 04:08:13
Subject: Re: why does swap not recover?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group