mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Optimize performance of my_bitmap
MDEV-33502 Slowdown when running nested statement with many partitions This change was triggered to help some MariaDB users with close to 10000 bits in their bitmaps. - Change underlaying storage to be 64 bit instead of 32bit. - This reduses number of loops to scan bitmaps. - This can cause some bitmaps to be 4 byte large. - Ensure that all not used top-bits are always 0 (simplifes code as the last 64 bit storage is not a special case anymore). - Use my_find_first_bit() to find the first set bit which is much faster than scanning trough things byte by byte and then bit by bit. Other things: - Added a bool to remember if my_bitmap_init() did allocate the bitmap array. my_bitmap_free() will only free arrays it did allocate. This allowed me to remove setting 'bitmap=0' before calling my_bitmap_free() for cases where the bitmap's where allocated externally. - my_bitmap_init() sets bitmap to 0 in case of failure. - Added 'universal' asserts to most bitmap functions. - Change all remaining calls to bitmap_init() to my_bitmap_init(). - To finish the change from 2014. - Changed all usage of uint32 in my_bitmap.h to my_bitmap_map. - Updated bitmap_copy() to handle bitmaps of different size. - Removed const from bitmap_exists_intersection() as this caused casts on all usage. - Removed not used function bitmap_set_above(). - Renamed create_last_word_mask() to create_last_bit_mask() (to match name changes in my_bitmap.cc) - Extended bitmap-t with test for more bitmap functions.
This commit is contained in:
@@ -3582,7 +3582,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
|
||||
table->reginfo.impossible_range= 0;
|
||||
|
||||
uint used_fields_buff_size= bitmap_buffer_size(table->s->fields);
|
||||
uint32 *used_fields_buff= (uint32*)thd->alloc(used_fields_buff_size);
|
||||
my_bitmap_map *used_fields_buff= (my_bitmap_map*)thd->alloc(used_fields_buff_size);
|
||||
MY_BITMAP cols_for_indexes;
|
||||
(void) my_bitmap_init(&cols_for_indexes, used_fields_buff, table->s->fields, 0);
|
||||
bitmap_clear_all(&cols_for_indexes);
|
||||
@@ -7439,7 +7439,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
|
||||
(*scan)->used_fields_covered=
|
||||
bitmap_bits_set(&(*scan)->covered_fields);
|
||||
(*scan)->first_uncovered_field=
|
||||
bitmap_get_first(&(*scan)->covered_fields);
|
||||
bitmap_get_first_clear(&(*scan)->covered_fields);
|
||||
}
|
||||
|
||||
my_qsort(ror_scan_mark, ror_scans_end-ror_scan_mark, sizeof(ROR_SCAN_INFO*),
|
||||
|
Reference in New Issue
Block a user