Table Maintenance Statements • RENAME TABLE  does not remove histograms. Instead, it renames histograms for the renamed table to be associated with the new table name. • ALTER TABLE  statements that remove or modify a column remove histograms for that column. • ALTER TABLE ... CONVERT TO CHARACTER SET  removes histograms for character columns because they are affected by the change of character set. Histograms for noncharacter columns remain unaffected. The  histogram_generation_max_mem_size  system variable controls the maximum amount of memory available for histogram generation. The global and session values may be set at runtime. Changing the global  histogram_generation_max_mem_size  value requires privileges sufficient to set global system variables. Changing the session  histogram_generation_max_mem_size  value requires privileges sufficient to set restricted session system variables. See Section 5.1.9.1, “System Variable Privileges” . If the estimated amount of data to be read into memory for histogram generation exceeds the limit defined by  histogram_generation_max_mem_size , MySQL samples the data rather than reading all of it into memory. Sampling is evenly distributed over the entire table. MySQL uses  SYSTEM  sampling, which is a page-level sampling method. The  sampling-rate  value in the  HISTOGRAM  column of  INFORMATION_SCHEMA.COLUMN_STATISTICS table can be queried to determine the fraction of data that was sampled to create the histogram. The sampling-rate  is a number between 0.0 and 1.0. A value of 1 means that all of the data was read (no sampling). The following example demonstrates sampling. To ensure that the amount of data exceeds the histogram_generation_max_mem_size  limit for the purpose of the example, the limit is set to a low value (2000000 bytes) prior to generating histogram statistics for the  birth_date  column of the employees  table. A  sampling-rate  value of 0.0491431208869665 means that approximately 4.9% of the data from the birth_date  column was read into memory for generating histogram statistics. As of MySQL 8.0.19, the  InnoDB  storage engine provides its own sampling implementation for data stored in  InnoDB  tables. The default sampling implementation used by MySQL when storage engines do not provide their own requires a full table scan, which is costly for large tables. The  InnoDB  sampling implementation improves sampling performance by avoiding full table scans. 2889 mysql>  SET histogram_generation_max_mem_size = 2000000; mysql>  USE employees; mysql>  ANALYZE TABLE employees UPDATE HISTOGRAM ON birth_date WITH 16 BUCKETS\G *************************** 1. row *************************** Table: employees.employees Op: histogram Msg_type: status Msg_text: Histogram statistics created for column ’birth_date’. mysql>  SELECT HISTOGRAM->>’$."sampling-rate"’ FROM INFORMATION_SCHEMA.COLUMN_STATISTICS WHERE TABLE_NAME = "employees" AND COLUMN_NAME = "birth_date"; +---------------------------------+ | HISTOGRAM->>’$."sampling-rate"’ | +---------------------------------+ | 0.0491431208869665 | +---------------------------------+