diff options
author | Monty <monty@mariadb.org> | 2022-12-20 15:55:40 +0200 |
---|---|---|
committer | Sergei Petrunia <sergey@mariadb.com> | 2023-02-03 14:38:26 +0300 |
commit | ed0a72356691bdeb163b52fb73bd0afa7b9254ac (patch) | |
tree | 2562a6cdddca6e3c606cc5588598841af423b3d1 /sql/table.cc | |
parent | 5e0832e1321391f3e780280668e8ef3ac6db99bd (diff) | |
download | mariadb-git-ed0a72356691bdeb163b52fb73bd0afa7b9254ac.tar.gz |
Cache file->index_flags(index, 0, 1) in table->key_info[index].index_flags
The reason for this is that we call file->index_flags(index, 0, 1)
multiple times in best_access_patch()when optimizing a table.
For example, in InnoDB, the calls is not trivial (4 if's and 2 assignments)
Now the function is inlined and is just a memory reference.
Other things:
- handler::is_clustering_key() and pk_is_clustering_key() are now inline.
- Added TABLE::can_use_rowid_filter() to simplify some code.
- Test if we should use a rowid_filter only if can_use_rowid_filter() is
true.
- Added TABLE::is_clustering_key() to avoid a memory reference.
- Simplify some code using the fact that HA_KEYREAD_ONLY is true implies
that HA_CLUSTERED_INDEX is false.
- Added DBUG_ASSERT to TABLE::best_range_rowid_filter() to ensure we
do not call it with a clustering key.
- Reorginized elements in struct st_key to get better memory alignment.
- Updated ha_innobase::index_flags() to not have
HA_DO_RANGE_FILTER_PUSHDOWN for clustered index
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/table.cc b/sql/table.cc index 0e196b64379..df4d88a1527 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -7411,7 +7411,7 @@ MY_BITMAP *TABLE::prepare_for_keyread(uint index, MY_BITMAP *map) DBUG_ENTER("TABLE::prepare_for_keyread"); if (!no_keyread) file->ha_start_keyread(index); - if (map != read_set || !(file->index_flags(index, 0, 1) & HA_CLUSTERED_INDEX)) + if (map != read_set || !is_clustering_key(index)) { mark_index_columns(index, map); column_bitmaps_set(map); @@ -8342,6 +8342,11 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, key_start= FALSE; key_part_info++; } + /* + We have to cache index_flags here as the table may be used by the + optimizer before it's opened. + */ + keyinfo->index_flags= file->index_flags(key, 0, 1); /* For the case when there is a derived table that would give distinct rows, |