Statistics for deleted tables in system.table_statistics do not get removed #94195
Labels
A-sql-table-stats
Table statistics (and their automatic refresh).
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
docs-done
docs-known-limitation
E-quick-win
Likely to be a quick win for someone experienced.
T-sql-queries
SQL Queries Team
Describe the problem
The problem was first noticed when performance of
SHOW TABLES
on a specific cluster slowed to > 60 seconds. A statement trace showed that most time was spent on the following query to thesystem.table_statistics
table:The
system.table_statistics
table had grown quite large (> 5 million rows) and appeared to retain statistics on deleted tables.To Reproduce
Start a single node.
Query for the count of rows in
system.table_statistics
by database name. A watch provides repeated output of the command.(it may take a couple of minutes for the statistics to show for system tables)
Set the
gc.ttlseconds
on the default range to500
seconds to force garbage collection of the table:Create a database and table:
Observe that rows in
system.table_statistics
are created for the table.(it may take a couple of minutes for the statistics to show for the newly created table)
Drop the database:
Observe that the rows for the table are not deleted, even after waiting until garbage collection completes (5 minutes).
Expected behavior
When a table is dropped, either directly or via dropping a database, the related rows in
system.table_statistics
are deleted. This prevents accumulation of orphaned rows that can slow down the performance ofSHOW TABLES
.Additional data / screenshots
None
Environment:
Additional context
May impact other queries or cluster operations.
Jira issue: CRDB-22733
The text was updated successfully, but these errors were encountered: