empty table explain... - Mailing list pgsql-general

From Luca Ferrari
Subject empty table explain...
Date
Msg-id 200810271743.14765.fluca1978@infinito.it
Whole thread Raw
Responses Re: empty table explain...  (Sam Mason <sam@samason.me.uk>)
Re: empty table explain...  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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


pgsql-general by date:

Previous
From: Mark Cave-Ayland
Date:
Subject: PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?
Next
From: Emmanuel Cecchet
Date:
Subject: Re: [HACKERS] Hot Standby utility and administrator functions