-
Norvald H. Ryeng authored
NON-PRIMARY INDEXES Problem: When adding a spatial index to a MyISAM table, the cardinality of other indexes may become incorrect. When doing ANALYZE TABLE, ha_myisam::analyze() calls chk_key() to gather statistics about each index. Then, chk_keys() calls update_key_parts() to generate a rows per key estimate for each key part (i.e., column) of the index. For B-tree indexes, there is one key part per column, and one key segment for each key part. For R-trees, there is always just one column and one key part, but four segments. The chk_key() and update_key_parts() functions assume that there are as many key parts as there are segments, and therefore generates four records per key estimates for each R-tree instead of just one. These estimates are then stored and later read back and assumed to be the estimates of the three subsequent key parts, which are part of other indexes. The estimate is then used to generate an estimate for the index cardinality. Fix: Write only one records per key estimate for each R-tree index.
Norvald H. Ryeng authoredNON-PRIMARY INDEXES Problem: When adding a spatial index to a MyISAM table, the cardinality of other indexes may become incorrect. When doing ANALYZE TABLE, ha_myisam::analyze() calls chk_key() to gather statistics about each index. Then, chk_keys() calls update_key_parts() to generate a rows per key estimate for each key part (i.e., column) of the index. For B-tree indexes, there is one key part per column, and one key segment for each key part. For R-trees, there is always just one column and one key part, but four segments. The chk_key() and update_key_parts() functions assume that there are as many key parts as there are segments, and therefore generates four records per key estimates for each R-tree instead of just one. These estimates are then stored and later read back and assumed to be the estimates of the three subsequent key parts, which are part of other indexes. The estimate is then used to generate an estimate for the index cardinality. Fix: Write only one records per key estimate for each R-tree index.
Loading