empty table explain...

From: Luca Ferrari <fluca1978(at)infinito(dot)it>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: empty table explain...
Date: 2008-10-27 16:43:08
Message-ID: 200810271743.14765.fluca1978@infinito.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,
I'm curious to know why, if a table is empty, it seems that an ANALYZE of the
table does not insert any stats in the pg_stats table, since maybe this could
be useful to solve joins including this table. Second, if I execute an EXPLAIN
on an empty table, even after an ANALYZE of the table, I got an explain that
proposes me a row numbers and size that I cannot understand (since it seems to
be different depending on the table definition).
As an example:

# create table test(id serial, descrizione character varying(20));

# explain select * from test;
QUERY PLAN
--------------------------------------------------------
Seq Scan on test (cost=0.00..18.80 rows=880 width=62)

# analyze verbose test;
INFO: ?analyzing "public.test"
INFO: ?"test": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0
rows in sample, 0 estimated total rows
ANALYZE

# explain select * from test;
? ? ? ? ? ? ? ? ? ? ? ?QUERY PLAN
--------------------------------------------------------
?Seq Scan on test ?(cost=0.00..18.80 rows=880 width=62)
(1 row)

# select count(*) from test;
?count
-------
? ? ?0
(1 row)

I know it does not make sense having an empty table or worrying about, but I'm
just curious to know if there's a particular reason for the above behaviours.

Thanks,
Luca

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Emmanuel Cecchet 2008-10-27 16:53:37 Re: [HACKERS] Hot Standby utility and administrator functions
Previous Message Mark Cave-Ayland 2008-10-27 16:39:04 PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?