diff options
author | sergefp@mysql.com <> | 2006-02-11 21:51:43 +0300 |
---|---|---|
committer | sergefp@mysql.com <> | 2006-02-11 21:51:43 +0300 |
commit | f95b5b0a5dc1f5a6d4a5c088b9b5704160f6e2f0 (patch) | |
tree | d894a207a1c4fad592a93902aac288cb1c465a91 /myisammrg | |
parent | 6fe11666fd6ec9745fec989289b7bcbd4e458c0f (diff) | |
download | mariadb-git-f95b5b0a5dc1f5a6d4a5c088b9b5704160f6e2f0.tar.gz |
BUG#17314: Can't use index_merge/intersection for MERGE tables
1. Fix index access costs for MERGE tables, set block_size=myisam_block_size/#underlying_tables
instead of 0 which it was before.
2. Make index scans on MERGE table to return records in (key_tuple, merge_table_rowid) order,
instead of just (key_tuple) order. This makes an index scan on MERGE table to be truly a ROR-scan
which is a requirement for index_merge union/intersection.
Diffstat (limited to 'myisammrg')
-rw-r--r-- | myisammrg/myrg_queue.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/myisammrg/myrg_queue.c b/myisammrg/myrg_queue.c index 7172b9f0e2a..2e600a526c0 100644 --- a/myisammrg/myrg_queue.c +++ b/myisammrg/myrg_queue.c @@ -18,12 +18,26 @@ static int queue_key_cmp(void *keyseg, byte *a, byte *b) { - MI_INFO *aa=((MYRG_TABLE *)a)->table; - MI_INFO *bb=((MYRG_TABLE *)b)->table; + MYRG_TABLE *ma= (MYRG_TABLE *)a; + MYRG_TABLE *mb= (MYRG_TABLE *)b; + MI_INFO *aa= ma->table; + MI_INFO *bb= mb->table; uint not_used[2]; int ret= ha_key_cmp((HA_KEYSEG *)keyseg, aa->lastkey, bb->lastkey, USE_WHOLE_KEY, SEARCH_FIND, not_used); - return ret < 0 ? -1 : ret > 0 ? 1 : 0; + if (ret < 0) + return -1; + if (ret > 0) + return 1; + + /* + If index tuples have the same values, let the record with least rowid + value be "smaller", so index scans return records ordered by (keytuple, + rowid). This is used by index_merge access method, grep for ROR in + sql/opt_range.cc for details. + */ + return (ma->file_offset < mb->file_offset)? -1 : (ma->file_offset > + mb->file_offset) ? 1 : 0; } /* queue_key_cmp */ |