MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
btr0sea.cc File Reference
#include "btr0sea.h"
#include "buf0buf.h"
#include "page0page.h"
#include "page0cur.h"
#include "btr0cur.h"
#include "btr0pcur.h"
#include "btr0btr.h"
#include "ha0ha.h"
Include dependency graph for btr0sea.cc:

Go to the source code of this file.

Macros

#define BTR_SEARCH_PAGE_BUILD_LIMIT   16
#define BTR_SEARCH_BUILD_LIMIT   100

Functions

UNIV_INTERN void btr_search_sys_create (ulint hash_size)
UNIV_INTERN void btr_search_sys_free (void)
UNIV_INTERN void btr_search_disable (void)
UNIV_INTERN void btr_search_enable (void)
UNIV_INTERN btr_search_tbtr_search_info_create (mem_heap_t *heap)
UNIV_INTERN ulint btr_search_info_get_ref_count (btr_search_t *info)
UNIV_INTERN void btr_search_info_update_slow (btr_search_t *info, btr_cur_t *cursor)
UNIV_INTERN ibool btr_search_guess_on_hash (dict_index_t *index, btr_search_t *info, const dtuple_t *tuple, ulint mode, ulint latch_mode, btr_cur_t *cursor, ulint has_search_latch, mtr_t *mtr)
UNIV_INTERN void btr_search_drop_page_hash_index (buf_block_t *block)
UNIV_INTERN void btr_search_drop_page_hash_when_freed (ulint space, ulint zip_size, ulint page_no)
UNIV_INTERN void btr_search_move_or_delete_hash_entries (buf_block_t *new_block, buf_block_t *block, dict_index_t *index)
UNIV_INTERN void btr_search_update_hash_on_delete (btr_cur_t *cursor)
UNIV_INTERN void btr_search_update_hash_node_on_insert (btr_cur_t *cursor)
UNIV_INTERN void btr_search_update_hash_on_insert (btr_cur_t *cursor)

Variables

UNIV_INTERN char btr_search_enabled = TRUE
UNIV_INTERN ulint btr_search_this_is_zero = 0
UNIV_INTERN byte btr_sea_pad1 [64]
UNIV_INTERN rw_lock_tbtr_search_latch_temp
 The latch protecting the adaptive search system.
UNIV_INTERN byte btr_sea_pad2 [64]
UNIV_INTERN btr_search_sys_tbtr_search_sys

Detailed Description

The index tree adaptive search

Created 2/17/1996 Heikki Tuuri

Definition in file btr0sea.cc.

Macro Definition Documentation

#define BTR_SEARCH_BUILD_LIMIT   100
The global limit for consecutive potentially successful hash searches,

before hash index building is started

Definition at line 94 of file btr0sea.cc.

#define BTR_SEARCH_PAGE_BUILD_LIMIT   16
If the number of records on the page divided by this parameter

would have been successfully accessed using a hash index, the index is then built on the page, assuming the global limit has been reached

Definition at line 90 of file btr0sea.cc.

Function Documentation

UNIV_INTERN void btr_search_disable ( void  )

Disable the adaptive hash search system and empty the index.

Definition at line 228 of file btr0sea.cc.

Here is the call graph for this function:

UNIV_INTERN void btr_search_drop_page_hash_index ( buf_block_t block)

Drops a page hash index.

Parameters
blockin: block containing index page, s- or x-latched, or an index page for which we know that block->buf_fix_count == 0 or it is an index page which has already been removed from the buf_pool->page_hash i.e.: it is in state BUF_BLOCK_REMOVE_HASH

Definition at line 1053 of file btr0sea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void btr_search_drop_page_hash_when_freed ( ulint  space,
ulint  zip_size,
ulint  page_no 
)

Drops a possible page hash index when a page is evicted from the buffer pool or freed in a file segment.

Parameters
spacein: space id
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
page_noin: page number

Definition at line 1258 of file btr0sea.cc.

Here is the call graph for this function:

UNIV_INTERN void btr_search_enable ( void  )

Enable the adaptive hash search system.

Definition at line 268 of file btr0sea.cc.

UNIV_INTERN ibool btr_search_guess_on_hash ( dict_index_t index,
btr_search_t info,
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. Note that if mode is PAGE_CUR_LE, which is used in inserts, and the function returns TRUE, then cursor->up_match and cursor->low_match both have sensible values.

Returns
TRUE if succeeded
Parameters
indexin: index
infoin: index search info
tuplein: logical record
modein: PAGE_CUR_L, ...
latch_modein: BTR_SEARCH_LEAF, ...; NOTE that only if has_search_latch is 0, we will have a latch set on the cursor page, otherwise we assume the caller uses his search latch to protect the record!
cursorout: tree cursor
has_search_latchin: latch mode the caller currently has on btr_search_latch: RW_S_LATCH, RW_X_LATCH, or 0
mtrin: mtr

Definition at line 847 of file btr0sea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN btr_search_t* btr_search_info_create ( mem_heap_t heap)

Creates and initializes a search info struct.

Returns
own: search info struct
Parameters
heapin: heap where created

Definition at line 283 of file btr0sea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint btr_search_info_get_ref_count ( btr_search_t info)

Returns the value of ref_count. The value is protected by btr_search_latch.

Returns
ref_count value.
Parameters
infoin: search info.

Definition at line 325 of file btr0sea.cc.

UNIV_INTERN void btr_search_info_update_slow ( btr_search_t info,
btr_cur_t cursor 
)

Updates the search info.

Parameters
infoin/out: search info
cursorin: cursor which was just positioned

Definition at line 620 of file btr0sea.cc.

UNIV_INTERN void btr_search_move_or_delete_hash_entries ( buf_block_t new_block,
buf_block_t block,
dict_index_t index 
)

Moves or deletes hash entries for moved records. If new_page is already hashed, then the hash index for page, if any, is dropped. If new_page is not hashed, and page is hashed, then a new hash index is built to new_page with the same parameters as page (this often happens when a page is split).

Parameters
new_blockin: records are copied to this page
blockin: index page from which records were copied, and the copied records will be deleted from this page
indexin: record descriptor

Definition at line 1497 of file btr0sea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void btr_search_sys_create ( ulint  hash_size)

Creates and initializes the adaptive search system at a database start.

Parameters
hash_sizein: hash index hash table size

Definition at line 163 of file btr0sea.cc.

Here is the caller graph for this function:

UNIV_INTERN void btr_search_sys_free ( void  )

Frees the adaptive search system at a database shutdown.

Definition at line 190 of file btr0sea.cc.

Here is the call graph for this function:

UNIV_INTERN 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.

Parameters
cursorin: cursor which was positioned to the place to insert using btr_cur_search_..., and the new record has been inserted next to the cursor

Definition at line 1624 of file btr0sea.cc.

Here is the call graph for this function:

UNIV_INTERN 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.

Parameters
cursorin: cursor which was positioned on the record to delete using btr_cur_search_..., the record is not yet deleted

Definition at line 1561 of file btr0sea.cc.

Here is the call graph for this function:

UNIV_INTERN 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.

Parameters
cursorin: cursor which was positioned to the place to insert using btr_cur_search_..., and the new record has been inserted next to the cursor

Definition at line 1689 of file btr0sea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

UNIV_INTERN byte btr_sea_pad1[64]
padding to prevent other memory update

hotspots from residing on the same memory cache line as btr_search_latch

Definition at line 63 of file btr0sea.cc.

UNIV_INTERN byte btr_sea_pad2[64]
padding to prevent other memory update hotspots from residing on

the same memory cache line

Definition at line 77 of file btr0sea.cc.

UNIV_INTERN char btr_search_enabled = TRUE
Flag: has the search system been enabled?

Protected by btr_search_latch.

Definition at line 48 of file btr0sea.cc.

UNIV_INTERN rw_lock_t* btr_search_latch_temp

The latch protecting the adaptive search system.

The latch protecting the adaptive search system: this latch protects the

(1) positions of records on those pages where a hash index has been built. NOTE: It does not protect values of non-ordering fields within a record from being updated in-place! We can use fact (1) to perform unique searches to indexes.

Definition at line 73 of file btr0sea.cc.

UNIV_INTERN btr_search_sys_t* btr_search_sys

The adaptive hash index

Definition at line 80 of file btr0sea.cc.

UNIV_INTERN ulint btr_search_this_is_zero = 0

A dummy variable to fool the compiler

Definition at line 51 of file btr0sea.cc.