pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tadipathri Raghu <traghu.dba@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Optimizer showing wrong rows in plan
Date: Sun, 28 Mar 2010 12:21:04 +0530
Message-ID: <645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com> (raw)

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

view thread (15+ messages)  latest in thread

Message-ID: <645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com>
Permalink:  ../645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com/
Also on:    postgresql.org/message-id/645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: traghu.dba@gmail.com
  Subject: Re: Optimizer showing wrong rows in plan
  In-Reply-To: <645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com>
  References: <645d9d71003272351x766707c7sadde9aa77bc1c0d3@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox