summaryrefslogtreecommitdiff
path: root/sql/ha_myisammrg.cc
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2006-02-11 21:51:43 +0300
committerunknown <sergefp@mysql.com>2006-02-11 21:51:43 +0300
commit4b0cce48737bf90eb33e389706df824cc00d7e5c (patch)
treed894a207a1c4fad592a93902aac288cb1c465a91 /sql/ha_myisammrg.cc
parent96268d4a9a375fdd6e7effe530f26261bbd01d55 (diff)
downloadmariadb-git-4b0cce48737bf90eb33e389706df824cc00d7e5c.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. myisammrg/myrg_queue.c: BUG#17314: Make index scans on MERGE table return records ordered by (keytuple, merge_table_rowid). mysql-test/r/index_merge.result: Testcase for BUG#17314 mysql-test/r/merge.result: BUG#17314: update testcase result mysql-test/t/index_merge.test: Testcase for BUG#17314 sql/ha_myisammrg.cc: BUG#17314: For MERGE tables, set handler::block_size to myisam_block_size/#underlying_tables, and not to 0.
Diffstat (limited to 'sql/ha_myisammrg.cc')
-rw-r--r--sql/ha_myisammrg.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index da4136def68..9780f163634 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -288,7 +288,27 @@ void ha_myisammrg::info(uint flag)
table->s->db_options_in_use= info.options;
table->s->is_view= 1;
mean_rec_length= info.reclength;
- block_size=0;
+
+ /*
+ The handler::block_size is used all over the code in index scan cost
+ calculations. It is used to get number of disk seeks required to
+ retrieve a number of index tuples.
+ If the merge table has N underlying tables, then (assuming underlying
+ tables have equal size, the only "simple" approach we can use)
+ retrieving X index records from a merge table will require N times more
+ disk seeks compared to doing the same on a MyISAM table with equal
+ number of records.
+ In the edge case (file_tables > myisam_block_size) we'll get
+ block_size==0, and index calculation code will act as if we need one
+ disk seek to retrieve one index tuple.
+
+ TODO: In 5.2 index scan cost calculation will be factored out into a
+ virtual function in class handler and we'll be able to remove this hack.
+ */
+ block_size= 0;
+ if (file->tables)
+ block_size= myisam_block_size / file->tables;
+
update_time=0;
#if SIZEOF_OFF_T > 4
ref_length=6; // Should be big enough