Обсуждение: Minor verbosity increase for analyze
Attached is a (very small) patch to make analyze display some interesting info in verbose mode about the analyzed relation (pages, rows per block and rows ). This is all available in the statistics catalog but I have found it useful to see it appear as you run... mods to : src/backend/commands/analyze.c plain diff against current CVS (31/07/2003 NZST) Best wishes Mark 696a697,702 > /* > * emit some interesting relation info > */ > elog(elevel, " pages = %d rows/page = %d rows = %d", > onerel->rd_nblocks, (int)tuplesperpage, (int)*totalrows); >
After browsing this list, I thought I would re-submit this in a more standard form. In addition I corrected a couple of things (integer cast for the number of rows, and capitalization in the comment) regards Mark --- src/backend/commands/analyze.c.orig 2003-07-31 20:49:22.000000000 -0400 +++ src/backend/commands/analyze.c 2003-07-31 20:49:29.000000000 -0400 @@ -694,6 +694,12 @@ */ *totalrows = floor((double) onerel->rd_nblocks * tuplesperpage + 0.5); + /* + * Emit some interesting relation info + */ + elog(elevel, " pages = %d rows/page = %d rows = %.0f", + onerel->rd_nblocks, (int)tuplesperpage, *totalrows); + return numrows; }
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches I will try to apply it within the next 48 hours. --------------------------------------------------------------------------- Mark Kirkwood wrote: > After browsing this list, I thought I would re-submit this in a more > standard form. > > In addition I corrected a couple of things (integer cast for the number > of rows, > and capitalization in the comment) > > regards > > Mark > > --- src/backend/commands/analyze.c.orig 2003-07-31 20:49:22.000000000 -0400 > +++ src/backend/commands/analyze.c 2003-07-31 20:49:29.000000000 -0400 > @@ -694,6 +694,12 @@ > */ > *totalrows = floor((double) onerel->rd_nblocks * tuplesperpage + 0.5); > > + /* > + * Emit some interesting relation info > + */ > + elog(elevel, " pages = %d rows/page = %d rows = %.0f", > + onerel->rd_nblocks, (int)tuplesperpage, *totalrows); > + > return numrows; > } > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Newest version of patch applied. Thanks. --------------------------------------------------------------------------- Mark Kirkwood wrote: > Attached is a (very small) patch to make analyze display some > interesting info in > verbose mode about the analyzed relation (pages, rows per block and rows ). > > This is all available in the statistics catalog but I have found it > useful to see it appear as > you run... > > mods to : > > src/backend/commands/analyze.c > > plain diff against current CVS (31/07/2003 NZST) > > Best wishes > > Mark > > > 696a697,702 > > /* > > * emit some interesting relation info > > */ > > elog(elevel, " pages = %d rows/page = %d rows = %d", > > onerel->rd_nblocks, (int)tuplesperpage, (int)*totalrows); > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
This was the actual patch applied. --------------------------------------------------------------------------- Mark Kirkwood wrote: > After browsing this list, I thought I would re-submit this in a more > standard form. > > In addition I corrected a couple of things (integer cast for the number > of rows, > and capitalization in the comment) > > regards > > Mark > > --- src/backend/commands/analyze.c.orig 2003-07-31 20:49:22.000000000 -0400 > +++ src/backend/commands/analyze.c 2003-07-31 20:49:29.000000000 -0400 > @@ -694,6 +694,12 @@ > */ > *totalrows = floor((double) onerel->rd_nblocks * tuplesperpage + 0.5); > > + /* > + * Emit some interesting relation info > + */ > + elog(elevel, " pages = %d rows/page = %d rows = %.0f", > + onerel->rd_nblocks, (int)tuplesperpage, *totalrows); > + > return numrows; > } > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Found some bugs with this patch - that makes it about 1 per line patched... :-( i) onerel->rd_nblocks should be elog'ed as an unsigned int. ii) acquire_sample_rows has 2 return points - I had ignored the case where the onerel has < sample size tuples in it. --- src/backend/commands/analyze.c.orig 2003-09-06 10:31:02.000000000 +1200 +++ src/backend/commands/analyze.c 2003-09-06 10:35:15.000000000 +1200 @@ -539,6 +539,9 @@ if (!HeapTupleIsValid(tuple)) { *totalrows = (double) numrows; + elog(elevel, " pages = %u rows = %.0f [smaller than sample size]", + onerel->rd_nblocks, *totalrows); /* display pages and rows */ + return numrows; } @@ -690,7 +693,7 @@ /* * Emit some interesting relation info */ - elog(elevel, " pages = %d rows/page = %d rows = %.0f", + elog(elevel, " pages = %u rows/page = %d rows = %.0f", onerel->rd_nblocks, (int)tuplesperpage, *totalrows); return numrows;
Mark Kirkwood <markir@paradise.net.nz> writes: > Found some bugs with this patch - that makes it about 1 per line > patched... :-( > i) onerel->rd_nblocks should be elog'ed as an unsigned int. > ii) acquire_sample_rows has 2 return points - I had ignored the case > where the > onerel has < sample size tuples in it. I've applied a variant of this. regards, tom lane