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