(2014/10/17 18:35), Etsuro Fujita wrote:
(2014/10/16 17:17), Simon Riggs wrote:
Would it be useful to keep track of how many tables just got analyzed?

i.e. analyze of foo (including N inheritance children)

I think that's a good idea.  So, I'll update the patch.

Done.  Attached is an updated version of the patch.

Thanks for the comment!

Best regards,
Etsuro Fujita
*** a/src/backend/commands/analyze.c
--- b/src/backend/commands/analyze.c
***************
*** 648,659 **** do_analyze_rel(Relation onerel, VacuumStmt *vacstmt,
  		if (Log_autovacuum_min_duration == 0 ||
  			TimestampDifferenceExceeds(starttime, GetCurrentTimestamp(),
  									   Log_autovacuum_min_duration))
! 			ereport(LOG,
! 					(errmsg("automatic analyze of table \"%s.%s.%s\" system usage: %s",
! 							get_database_name(MyDatabaseId),
! 							get_namespace_name(RelationGetNamespace(onerel)),
! 							RelationGetRelationName(onerel),
! 							pg_rusage_show(&ru0))));
  	}
  
  	/* Roll back any GUC changes executed by index functions */
--- 648,699 ----
  		if (Log_autovacuum_min_duration == 0 ||
  			TimestampDifferenceExceeds(starttime, GetCurrentTimestamp(),
  									   Log_autovacuum_min_duration))
! 		{
! 			if (inh)
! 			{
! 				List	   *tableOIDs;
! 				int			nchildren;
! 
! 				/*
! 				 * Find all members of inheritance set.
! 				 *
! 				 * Note: we already got the lock on children except for
! 				 * temp tables of other backends.  See
! 				 * acquire_inherited_sample_rows.
! 				 */
! 				tableOIDs =
! 					find_all_inheritors(RelationGetRelid(onerel), NoLock, NULL);
! 
! 				/*
! 				 * Compute the number of children.
! 				 *
! 				 * Note: this might contain temp tables of other backends,
! 				 * which we didn't analyze, unless those tables have been
! 				 * dropped concurrently.  We could get the number of children
! 				 * that we did analyze, if we were willing to change the API
! 				 * of acquire_inherited_sample_rows to output it, or check
! 				 * whether each child in tableOIDs is a temp table of another
! 				 * backend or not using RELATION_IS_OTHER_TEMP(), but it
! 				 * doesn't seem worth the code complexity or the overhead.
! 				 */
! 				nchildren = list_length(tableOIDs) - 1;
! 
! 				ereport(LOG,
! 						(errmsg("automatic analyze of table \"%s.%s.%s\" (including %d inheritance children) system usage: %s",
! 								get_database_name(MyDatabaseId),
! 								get_namespace_name(RelationGetNamespace(onerel)),
! 								RelationGetRelationName(onerel),
! 								nchildren,
! 								pg_rusage_show(&ru0))));
! 			}
! 			else
! 				ereport(LOG,
! 						(errmsg("automatic analyze of table \"%s.%s.%s\" system usage: %s",
! 								get_database_name(MyDatabaseId),
! 								get_namespace_name(RelationGetNamespace(onerel)),
! 								RelationGetRelationName(onerel),
! 								pg_rusage_show(&ru0))));
! 		}
  	}
  
  	/* Roll back any GUC changes executed by index functions */
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to