YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
void Rdb_tbl_prop_coll::AdjustDeletedRows(rocksdb::EntryType type) { if (m_params.m_window > 0) { // record the "is deleted" flag into the sliding window // the sliding window is implemented as a circular buffer // in m_deleted_rows_window vector // the current position in the circular buffer is pointed at by // m_rows % m_deleted_rows_window.size() // m_deleted_rows is the current number of 1's in the vector // --update the counter for the element which will be overridden constbool is_delete = (type == rocksdb::kEntryDelete ||
(type == rocksdb::kEntrySingleDelete &&
rocksdb_compaction_sequential_deletes_count_sd));
// Only make changes if the value at the current position needs to change if (is_delete != m_deleted_rows_window[m_window_pos]) { // Set or clear the flag at the current position as appropriate
m_deleted_rows_window[m_window_pos] = is_delete; if (!is_delete) {
m_deleted_rows--;
} elseif (++m_deleted_rows > m_max_deleted_rows) {
m_max_deleted_rows = m_deleted_rows;
}
}
// starting a new table // add the new element into m_stats
m_stats.emplace_back(gl_index_id);
m_last_stats = &m_stats.back();
if (m_ddl_manager) { // safe_find() returns a std::shared_ptr<Rdb_key_def> with the count // incremented (so it can't be deleted out from under us) and with // the mutex locked (if setup has not occurred yet). We must make // sure to free the mutex (via unblock_setup()) when we are done // with this object. Currently this happens earlier in this function // when we are switching to a new Rdb_key_def and when this object // is destructed.
m_keydef = m_ddl_manager->safe_find(gl_index_id); if (m_keydef != nullptr) { // resize the array to the number of columns. // It will be initialized with zeroes
m_last_stats->m_distinct_keys_per_prefix.resize(
m_keydef->get_key_parts());
m_last_stats->m_name = m_keydef->get_name();
}
}
m_cardinality_collector.Reset();
}
constint version = rdb_netbuf_read_uint16(&p);
Rdb_index_stats stats; // Make sure version is within supported range. if (version < INDEX_STATS_VERSION_INITIAL ||
version > INDEX_STATS_VERSION_ENTRY_TYPES) { // NO_LINT_DEBUG
sql_print_error( "Index stats version %d was outside of supported range. " "This should not happen so aborting the system.",
version);
abort();
}
bool Rdb_tbl_card_coll::IsSampingDisabled() { // Zero means that we'll use all the keys to update statistics. return m_table_stats_sampling_pct == 0 ||
RDB_TBL_STATS_SAMPLE_PCT_MAX == m_table_stats_sampling_pct;
}
bool Rdb_tbl_card_coll::ShouldCollectStats() { if (IsSampingDisabled()) { returntrue; // collect every key
}
if (new_key) {
DBUG_ASSERT(column <= stats->m_distinct_keys_per_prefix.size());
for (auto i = column; i < stats->m_distinct_keys_per_prefix.size(); i++) {
stats->m_distinct_keys_per_prefix[i]++;
}
// assign new last_key for the next call // however, we only need to change the last key // if one of the first n-1 columns is different // If the n-1 prefix is the same, no sense in storing // the new key if (column < stats->m_distinct_keys_per_prefix.size()) {
m_last_key.assign(key.data(), key.size());
}
}
}
}
// We need to adjust the index cardinality numbers based on the sampling // rate so that the output of "SHOW INDEX" command will reflect reality // more closely. It will still be an approximation, just a better one. void Rdb_tbl_card_coll::AdjustStats(Rdb_index_stats *stats) { if (IsSampingDisabled()) { // no sampling was done, return as stats is return;
} for (int64_t &num_keys : stats->m_distinct_keys_per_prefix) {
num_keys = num_keys * 100 / m_table_stats_sampling_pct;
}
}
} // namespace myrocks
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.