On Tue, Apr 1, 2008 at 1:22 AM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote: > > Please do --- I have a lot of other stuff on my plate. > Please see the attached patch. One change I made is to hold the SHARE lock on the page while ANALYZE is reading tuples from it. I thought it would be a right thing to do instead of repeatedly acquiring/releasing the lock. Another thing I noticed while working on this is VACUUM probably reports the number of dead tuples incorrectly. We don't count the DEAD line pointers as "tups_vacuumed" which is fine if the line pointer was marked DEAD in the immediately preceding heap_page_prune(). In that case the DEAD line pointer is counted in "ndeleted" count returned by heap_page_prune(). But it fails to count already DEAD line pointers. For example postgres=# CREATE TABLE test (a int, b char(500)); CREATE TABLE postgres=# INSERT INTO test VALUES (generate_series(1,15),'foo'); INSERT 0 15 postgres=# DELETE FROM test; DELETE 15 postgres=# select count(*) from test; count ------- 0 (1 row) postgres=# VACUUM VERBOSE test; INFO: vacuuming "public.test" INFO: "test": removed 0 row versions in 1 pages INFO: "test": found 0 removable, 0 nonremovable row versions in 1 pages DETAIL: 0 dead row versions cannot be removed yet. There were 0 unused item pointers. 1 pages contain useful free space. 0 pages are entirely empty. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: "test": truncated 1 to 0 pages DETAIL: CPU 0.00s/0.00u sec elapsed 0.00 sec. VACUUM So VACUUM reports "zero" dead row versions which may seem counter-intuitive especially in the autovac log message (as someone may wonder why autovac got triggered on the table) I am thinking we can make heap_page_prune() to only return number of HOT tuples pruned and then explicitly count the DEAD line pointers in tups_vacuumed. Thanks, Pavan -- Pavan Deolasee EnterpriseDB http://www.enterprisedb.com
Attachment:
Analyze-fix.patch.gz
Description: GNU Zip compressed data
-- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general