Below is the list of changes that have just been committed into a local
5.1 repository of gshchepa. When gshchepa does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-04-26 02:45:58+05:00, gshchepa@stripped +8 -0
Fixed bug#36006: Optimizer does table scan for SELECT COUNT(*)
for ENGINE=MRG_MYISAM (should be optimized out).
Before WL#3281 MERGE engine had the HA_NOT_EXACT_COUNT flag
unset, and it worked with COUNT optimization as desired.
After the removal of the HA_NOT_EXACT_COUNT flag neither
HA_STATS_RECORDS_IS_EXACT (opposite to former HA_NOT_EXACT_COUNT
flag) nor modern HA_HAS_RECORDS flag were not added to MERGE
table flag mask.
1. The HA_HAS_RECORDS table flag has been set.
2. The ha_myisammrg::records method has been overridden to
calculate total number of records in underlying tables.
include/myisammrg.h@stripped, 2008-04-26 02:24:31+05:00, gshchepa@stripped +1 -0
Fixed bug#36006: Optimizer does table scan for select count(*).
The myrg_records function declaration has been added.
mysql-test/r/merge.result@stripped, 2008-04-26 02:24:32+05:00, gshchepa@stripped +16 -0
Added test case for bug#36006.
mysql-test/t/merge.test@stripped, 2008-04-26 02:24:33+05:00, gshchepa@stripped +16 -0
Added test case for bug#36006.
storage/myisammrg/CMakeLists.txt@stripped, 2008-04-26 02:24:34+05:00, gshchepa@stripped +1 -1
Fixed bug#36006: Optimizer does table scan for select count(*).
New myrg_records.c file has been added.
storage/myisammrg/Makefile.am@stripped, 2008-04-26 02:24:35+05:00, gshchepa@stripped +1 -1
Fixed bug#36006: Optimizer does table scan for select count(*).
New myrg_records.c file has been added.
storage/myisammrg/ha_myisammrg.cc@stripped, 2008-04-26 02:24:36+05:00, gshchepa@stripped +6
-0
Fixed bug#36006: Optimizer does table scan for select count(*).
The ha_myisammrg::records method has been overridden.
storage/myisammrg/ha_myisammrg.h@stripped, 2008-04-26 02:24:36+05:00, gshchepa@stripped +2
-0
Fixed bug#36006: Optimizer does table scan for select count(*).
1. The HA_HAS_RECORDS table flag has been set.
2. The ha_myisammrg::records method has been overridden.
storage/myisammrg/myrg_records.c@stripped, 2008-04-26 02:21:46+05:00, gshchepa@stripped +27
-0
Fixed bug#36006: Optimizer does table scan for select count(*).
The myrg_records function has been added to calculate total number
of records in underlying tables.
storage/myisammrg/myrg_records.c@stripped, 2008-04-26 02:21:46+05:00, gshchepa@stripped +0 -0
diff -Nrup a/include/myisammrg.h b/include/myisammrg.h
--- a/include/myisammrg.h 2007-12-11 18:32:09 +04:00
+++ b/include/myisammrg.h 2008-04-26 02:24:31 +05:00
@@ -112,6 +112,7 @@ extern int myrg_reset(MYRG_INFO *info);
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
extern ha_rows myrg_records_in_range(MYRG_INFO *info, int inx,
key_range *min_key, key_range *max_key);
+extern ha_rows myrg_records(MYRG_INFO *info);
extern ulonglong myrg_position(MYRG_INFO *info);
#ifdef __cplusplus
diff -Nrup a/mysql-test/r/merge.result b/mysql-test/r/merge.result
--- a/mysql-test/r/merge.result 2008-03-15 22:28:17 +04:00
+++ b/mysql-test/r/merge.result 2008-04-26 02:24:32 +05:00
@@ -2006,3 +2006,19 @@ test.t1 optimize status OK
FLUSH TABLES m1, t1;
UNLOCK TABLES;
DROP TABLE t1, m1;
+CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
+CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
+CREATE TABLE t3(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
+CREATE TABLE t4(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2))
+ENGINE=MRG_MYISAM UNION=(t1, t2, t3);
+INSERT INTO t1 VALUES (1,1), (1,2),(1,3), (1,4);
+INSERT INTO t2 VALUES (2,1), (2,2),(2,3), (2,4);
+INSERT INTO t3 VALUES (3,1), (3,2),(3,3), (3,4);
+EXPLAIN SELECT COUNT(*) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+EXPLAIN SELECT COUNT(*) FROM t4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+DROP TABLE t1, t2, t3, t4;
+End of 5.1 tests
diff -Nrup a/mysql-test/t/merge.test b/mysql-test/t/merge.test
--- a/mysql-test/t/merge.test 2008-03-15 22:28:17 +04:00
+++ b/mysql-test/t/merge.test 2008-04-26 02:24:33 +05:00
@@ -1394,3 +1394,19 @@ FLUSH TABLES m1, t1;
UNLOCK TABLES;
DROP TABLE t1, m1;
+#
+# Bug#36006 - Optimizer does table scan for select count(*)
+#
+CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
+CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
+CREATE TABLE t3(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
+CREATE TABLE t4(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2))
+ ENGINE=MRG_MYISAM UNION=(t1, t2, t3);
+INSERT INTO t1 VALUES (1,1), (1,2),(1,3), (1,4);
+INSERT INTO t2 VALUES (2,1), (2,2),(2,3), (2,4);
+INSERT INTO t3 VALUES (3,1), (3,2),(3,3), (3,4);
+EXPLAIN SELECT COUNT(*) FROM t1;
+EXPLAIN SELECT COUNT(*) FROM t4;
+DROP TABLE t1, t2, t3, t4;
+
+--echo End of 5.1 tests
diff -Nrup a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt
--- a/storage/myisammrg/CMakeLists.txt 2008-01-30 06:58:55 +04:00
+++ b/storage/myisammrg/CMakeLists.txt 2008-04-26 02:24:34 +05:00
@@ -26,7 +26,7 @@ SET(MYISAMMRG_SOURCES myrg_close.c myrg
myrg_locking.c myrg_open.c myrg_panic.c myrg_queue.c myrg_range.c
myrg_rfirst.c myrg_rkey.c myrg_rlast.c myrg_rnext.c myrg_rnext_same.c
myrg_rprev.c myrg_rrnd.c myrg_rsame.c myrg_static.c myrg_update.c
- myrg_write.c)
+ myrg_write.c myrg_records.c)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(myisammrg ${MYISAMMRG_SOURCES})
diff -Nrup a/storage/myisammrg/Makefile.am b/storage/myisammrg/Makefile.am
--- a/storage/myisammrg/Makefile.am 2006-12-31 04:06:41 +04:00
+++ b/storage/myisammrg/Makefile.am 2008-04-26 02:24:35 +05:00
@@ -35,7 +35,7 @@ libmyisammrg_a_SOURCES = myrg_open.c myr
myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
ha_myisammrg.cc \
- myrg_rnext_same.c
+ myrg_rnext_same.c myrg_records.c
EXTRA_DIST = CMakeLists.txt plug.in
diff -Nrup a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
--- a/storage/myisammrg/ha_myisammrg.cc 2008-03-31 12:40:37 +05:00
+++ b/storage/myisammrg/ha_myisammrg.cc 2008-04-26 02:24:36 +05:00
@@ -1154,6 +1154,12 @@ int ha_myisammrg::check(THD* thd, HA_CHE
}
+ha_rows ha_myisammrg::records()
+{
+ return myrg_records(file);
+}
+
+
extern int myrg_panic(enum ha_panic_function flag);
int myisammrg_panic(handlerton *hton, ha_panic_function flag)
{
diff -Nrup a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
--- a/storage/myisammrg/ha_myisammrg.h 2007-11-15 23:25:41 +04:00
+++ b/storage/myisammrg/ha_myisammrg.h 2008-04-26 02:24:36 +05:00
@@ -42,6 +42,7 @@ class ha_myisammrg: public handler
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
HA_ANY_INDEX_MAY_BE_UNIQUE | HA_CAN_BIT_FIELD |
+ HA_HAS_RECORDS |
HA_NO_COPY_ON_ALTER);
}
ulong index_flags(uint inx, uint part, bool all_parts) const
@@ -94,4 +95,5 @@ class ha_myisammrg: public handler
TABLE *table_ptr() { return table; }
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
int check(THD* thd, HA_CHECK_OPT* check_opt);
+ ha_rows records();
};
diff -Nrup a/storage/myisammrg/myrg_records.c b/storage/myisammrg/myrg_records.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/myisammrg/myrg_records.c 2008-04-26 02:21:46 +05:00
@@ -0,0 +1,27 @@
+/* Copyright (C) 2008 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "myrg_def.h"
+
+ha_rows myrg_records(MYRG_INFO *info)
+{
+ ha_rows records=0;
+ MYRG_TABLE *file;
+ DBUG_ENTER("myrg_records");
+
+ for (file=info->open_tables ; file != info->end_table ; file++)
+ records+= file->table->s->state.state.records;
+ DBUG_RETURN(records);
+}
| Thread |
|---|
| • bk commit into 5.1 tree (gshchepa:1.2565) BUG#36006 | gshchepa | 25 Apr 2008 |