Configuring Optimizer Statistics for InnoDB to sample random pages from each index on a table to estimate the cardinality of the index. This sampling technique is known as a random dive. The  innodb_stats_persistent_sample_pages  controls the number of sampled pages. You can adjust the setting at runtime to manage the quality of statistics estimates used by the optimizer. The default value is 20. Consider modifying the setting when encountering the following issues: If it is determined that statistics are not accurate enough, the value of innodb_stats_persistent_sample_pages  should be increased until the statistics estimates are sufficiently accurate. Increasing  innodb_stats_persistent_sample_pages  too much, however, could cause  ANALYZE TABLE  to run slowly. If a balance cannot be achieved between accurate statistics and  ANALYZE TABLE  execution time, consider decreasing the number of indexed columns in the table or limiting the number of partitions to reduce  ANALYZE TABLE  complexity. The number of columns in the table’s primary key is also important to consider, as primary key columns are appended to each nonunique index. For related information, see Section 15.8.10.3, “Estimating ANALYZE TABLE Complexity for InnoDB Tables” . By default,  InnoDB  reads uncommitted data when calculating statistics. In the case of an uncommitted transaction that deletes rows from a table, delete-marked records are excluded when calculating row estimates and index statistics, which can lead to non-optimal execution plans for other transactions that are operating on the table concurrently using a transaction isolation level other than  READ UNCOMMITTED . To avoid this scenario,  innodb_stats_include_delete_marked  can be enabled to ensure that delete- marked records are included when calculating persistent optimizer statistics. When  innodb_stats_include_delete_marked  is enabled,  ANALYZE TABLE  considers delete- marked records when recalculating statistics. innodb_stats_include_delete_marked  is a global setting that affects all  InnoDB  tables, and it is only applicable to persistent optimizer statistics. The persistent statistics feature relies on the internally managed tables in the  mysql  database, named innodb_table_stats  and  innodb_index_stats . These tables are set up automatically in all install, upgrade, and build-from-source procedures. 3133 Table 15.6 Columns of innodb_table_stats Column name Description database_name Database name table_name Table name, partition name, or subpartition name InnoDB Persistent Statistics Tables Including Delete-marked Records in Persistent Statistics Calculations 1. Statistics are not accurate enough and the optimizer chooses suboptimal plans , as shown in EXPLAIN  output. You can check the accuracy of statistics by comparing the actual cardinality of an index (determined by running  SELECT DISTINCT  on the index columns) with the estimates in the mysql.innodb_index_stats  table. 2. ANALYZE TABLE  is too slow . In this case  innodb_stats_persistent_sample_pages  should be decreased until  ANALYZE TABLE  execution time is acceptable. Decreasing the value too much, however, could lead to the first problem of inaccurate statistics and suboptimal query execution plans.