70 static_assert(
decltype(
prefix_info)::is_always_lock_free);
71#ifdef UNIV_SEARCH_PERF_STAT
73 std::atomic<ulint> n_hash_succ;
75 std::atomic<ulint> n_hash_fail;
77 std::atomic<ulint> n_patt_succ;
79 std::atomic<ulint> n_searches;
328#ifdef UNIV_SEARCH_PERF_STAT
330extern ulint btr_search_n_succ;
332extern ulint btr_search_n_hash_fail;
void btr_search_drop_page_hash_index(buf_block_t *block, bool force=false)
Drop any adaptive hash index entries that point to an index page.
Definition: btr0sea.cc:1006
constexpr uint32_t BTR_SEARCH_ON_HASH_LIMIT
Limit of consecutive searches for trying a search shortcut using the hash index.
Definition: btr0sea.h:346
bool btr_search_disable()
Disable the adaptive hash search system and empty the index.
Definition: btr0sea.cc:314
static rw_lock_t * btr_get_search_latch(const dict_index_t *index)
Get the latch based on index attributes.
void btr_search_update_hash_on_move(buf_block_t *new_block, buf_block_t *block, dict_index_t *index)
Moves or deletes hash entries for moved records.
Definition: btr0sea.cc:1581
static void btr_search_s_unlock(const dict_index_t *index)
S-Unlock the search latch (corresponding to given index)
bool btr_search_validate()
Validates the search system.
Definition: btr0sea.cc:2048
static bool btr_search_s_lock_nowait(const dict_index_t *index, ut::Location location)
S-Lock the search latch (corresponding to given index), does not block.
void btr_search_update_hash_on_insert(btr_cur_t *cursor)
Updates the page hash index when a single record is inserted on a page.
Definition: btr0sea.cc:1737
static size_t btr_search_hash_index_id(const dict_index_t *index)
Compute a hash value for a specified index.
constexpr uint32_t BTR_SEARCH_MAGIC_N
value of btr_search_t::magic_n, used in assertions
Definition: btr0sea.h:89
static void btr_search_x_unlock_all()
Unlock all search latches from exclusive mode.
void btr_search_sys_free()
Frees the adaptive search system at a database shutdown.
Definition: btr0sea.cc:256
void btr_search_update_hash_on_delete(btr_cur_t *cursor)
Updates the page hash index when a single record is deleted from a page.
Definition: btr0sea.cc:1632
static void btr_search_x_lock(const dict_index_t *index, ut::Location location)
X-Lock the search latch (corresponding to given index)
static class btr_search_sys_t::search_part_t & btr_get_search_part(const dict_index_t *index)
Gets a pointer to a adaptive search part structure for a specified index.
static void btr_search_s_unlock_all()
Unlock all search latches from shared mode.
btr_search_t * btr_search_info_create(mem_heap_t *heap)
Creates and initializes a search info struct.
Definition: btr0sea.cc:374
static bool btr_search_x_lock_nowait(const dict_index_t *index, ut::Location location)
X-Lock the search latch (corresponding to given index), does not block.
void btr_search_await_no_reference(dict_table_t *table, dict_index_t *index, bool force)
Wait for the specified index to have all references from AHI dropped.
Definition: btr0sea.cc:273
void btr_search_set_block_not_cached(buf_block_t *block)
Resets block's AHI index field to nullptr, removes the reference from index's reference counter.
Definition: btr0sea.cc:1226
static bool btr_search_own_any(ulint mode)
Check if thread owns any of the search latches.
static void btr_search_x_lock_all(ut::Location location)
Lock all search latches in exclusive mode.
constexpr uint32_t BTR_SEARCH_ON_PATTERN_LIMIT
Limit of consecutive searches for trying a search shortcut on the search pattern.
Definition: btr0sea.h:342
void btr_search_sys_resize(ulint hash_size)
Resize hash index hash table.
Definition: btr0sea.cc:223
void btr_search_sys_create(ulint hash_size)
Creates and initializes the adaptive search system at a database start.
Definition: btr0sea.cc:186
static bool btr_search_own_all(ulint mode)
Check if thread owns all the search latches.
void btr_drop_ahi_for_index(const dict_index_t *index)
Drop any adaptive hash index entries for a index.
Definition: btr0sea.cc:1384
void btr_drop_ahi_for_table(dict_table_t *table)
Drop any adaptive hash index entries for a table.
Definition: btr0sea.cc:1347
btr_search_sys_t * btr_search_sys
The adaptive hash index.
Definition: btr0sea.cc:85
bool btr_search_guess_on_hash(const dtuple_t *tuple, ulint mode, ulint latch_mode, btr_cur_t *cursor, ulint has_search_latch, mtr_t *mtr)
Tries to guess the right search position based on the hash search info of the index.
Definition: btr0sea.cc:805
constexpr uint32_t BTR_SEARCH_HASH_ANALYSIS
After change in n_fields or n_bytes in info, this many rounds are waited before starting the hash ana...
Definition: btr0sea.h:338
void btr_search_drop_page_hash_when_freed(const page_id_t &page_id, const page_size_t &page_size)
Drop any adaptive hash index entries that may point to an index page that may be in the buffer pool,...
Definition: btr0sea.cc:1259
static void btr_search_info_update(btr_cur_t *cursor)
Updates the search info statistics following a search in B-tree that was performed not using or not f...
static void btr_search_s_lock_all(ut::Location location)
Lock all search latches in shared mode.
void btr_search_enable()
Enable the adaptive hash search system.
Definition: btr0sea.cc:359
void btr_search_update_hash_node_on_insert(btr_cur_t *cursor)
Updates the page hash index when a single record is inserted on a page.
Definition: btr0sea.cc:1687
static void btr_search_s_lock(const dict_index_t *index, ut::Location location)
S-Lock the search latch (corresponding to given index)
static void btr_search_x_unlock(const dict_index_t *index)
X-Unlock the search latch (corresponding to given index)
The index tree adaptive search.
The index tree general types.
std::atomic< buf_block_t * > free_block_for_heap
A pointer to a free block that the heap in the hash table may use for adding new hash nodes.
Definition: btr0sea.h:115
hash_table_t * hash_table
The adaptive hash table, mapping dtuple_hash values to rec_t pointers on index pages.
Definition: btr0sea.h:110
rw_lock_t latch
The latch protecting the adaptive search part: this latch protects the (1) positions of records on th...
Definition: btr0sea.h:105
void initialize(size_t hash_size)
Definition: btr0sea.cc:209
The hash index system.
Definition: btr0sea.h:93
btr_search_sys_t(size_t hash_size)
Definition: btr0sea.cc:195
ut::unique_ptr_aligned< search_part_t[]> parts
Partitions of the AHI system.
Definition: btr0sea.h:119
Definition: hash0hash.h:375
Page identifier.
Definition: buf0types.h:207
Page size descriptor.
Definition: page0size.h:50
The hash table with external chains.
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
mode
Definition: file_handle.h:61
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:41
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Aligned_deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Aligned_array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr_aligned
The following is a common type that is returned by all the ut::make_unique_aligned (non-aligned) spec...
Definition: ut0new.h:2573
The tree cursor: the definition appears here only for the compiler to know struct size!
Definition: btr0cur.h:668
The search info struct in an index.
Definition: btr0sea.h:46
std::atomic< btr_search_prefix_info_t > prefix_info
Definition: btr0sea.h:69
bool last_hash_succ
true if the last search would have succeeded, or did succeed, using the hash index; NOTE that the val...
Definition: btr0sea.h:63
ulint magic_n
magic number
Definition: btr0sea.h:70
std::atomic< uint64_t > hash_analysis
when this exceeds BTR_SEARCH_HASH_ANALYSIS, the hash analysis starts; this is reset if no success not...
Definition: btr0sea.h:59
buf_block_t * root_guess
the root page frame when it was last time fetched, or NULL.
Definition: btr0sea.h:56
std::atomic< uint64_t > n_hash_potential
number of consecutive searches which would have succeeded, or did succeed, using the hash index; the ...
Definition: btr0sea.h:66
std::atomic< size_t > ref_count
Number of blocks in this index tree that have search index built i.e.
Definition: btr0sea.h:49
The buffer control block structure.
Definition: buf0buf.h:1747
Data structure for an index.
Definition: dict0mem.h:1046
Data structure for a database table.
Definition: dict0mem.h:1909
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:694
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:177
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:363
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406