Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#22028] YSQL: Add yb_reset_analyze_statistics function
Summary: Add function that resets the stats collected by ANALYZE command. Function Description: ``` yb_reset_analyze_statistics ( table_oid ) → void Resets the statistics of a table collected by the ANALYZE command. if table_oid is NULL, this function resets the statistics for all the tables in the current database that the user can analyze. ``` What this function resets: * `reltuple`s of the table and the indexes in `pg_class` are set to 0. * The rows in `pg_statistic` that corresponds to each table column are deleted. * The values of extended statistics in `pg_statistic_ext`, if created, are set to NULL. (The rows in `pg_statistic_ext` are managed by `CREATE/ALTER/DROP STATISTICS` commands, and their statistic values are populated by the ANALYZE command.) * After modifying the system catalog entries described above, this function increment the YB catalog version of the current database for propagation. What this function does not reset: * Each sequence object has fixed value of 1 in `reltuples`. This is not collected by or updated by the ANALYZE command, and this function does not reset it, either. Who can reset what: * Only superusers can reset the stats for the tables shared across all the databases (e.g.: `pg_database`). * Non-superuser current database owner can reset the stats for any non-shared table in the database including the ones in `pg_catalog` and `information_schema` namespaces. Limitation and potential follow-on work: * Invalid or irrelevant table_oid argument will be silently ignored. If more informative error handling is required, this would have to be implemented as either a PL/PgSQL function (then load it after the load_plpgsql() call in initdb) or a C function. Jira: DB-10945 Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressAnalyze' ./yb_build.sh --java-test 'org.yb.pgsql.TestYsqlUpgrade' Reviewers: tnayak Reviewed By: tnayak Subscribers: yql, smishra, mihnea Differential Revision: https://phorge.dev.yugabyte.com/D35829
- Loading branch information