From 15d2a52ba52fc416fedcaf9088ede1def470a6fc Mon Sep 17 00:00:00 2001 From: Jordan Lewis Date: Sun, 16 Jun 2019 15:42:55 -0400 Subject: [PATCH] stats: don't try to make stats for dropped tables Previously, statistics collection would schedule checks for all tables at startup, including tables that have already been dropped. This was harmless but polluted the logs and lease caches. Now, statistics collection doesn't try to schedule checks for tables that are known to have been dropped already. Release note: None --- pkg/sql/stats/automatic_stats.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sql/stats/automatic_stats.go b/pkg/sql/stats/automatic_stats.go index d408ed04102f..9011331ce6ae 100644 --- a/pkg/sql/stats/automatic_stats.go +++ b/pkg/sql/stats/automatic_stats.go @@ -309,7 +309,11 @@ func (r *Refresher) ensureAllTables( // Use a historical read so as to disable txn contention resolution. getAllTablesQuery := fmt.Sprintf( - `SELECT table_id FROM crdb_internal.tables AS OF SYSTEM TIME '-%s' WHERE schema_name = 'public'`, + ` +SELECT table_id FROM crdb_internal.tables AS OF SYSTEM TIME '-%s' +WHERE schema_name = 'public' +AND drop_time IS NULL +`, initialTableCollectionDelay) rows, err := r.ex.Query(