summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2015-10-02 10:18:27 +0200
committerSergei Golubchik <serg@mariadb.org>2015-10-05 17:14:14 +0200
commitcf50e13fbd1b4d27a3542fe2751216d274eb7493 (patch)
tree2ff477367c13e63a50c2e13b00e0be79d65bc646 /sql/sql_select.h
parentd8df2b946442e6f4bd7dd73570a603ae3e2d21f0 (diff)
downloadmariadb-git-cf50e13fbd1b4d27a3542fe2751216d274eb7493.tar.gz
MDEV-6080: Allowing storage engine to shortcut group by queries
This task is to allow storage engines that can execute GROUP BY or summary queries efficiently to intercept a full query or sub query from MariaDB and deliver the result either to the client or to a temporary table for further processing. - Added code in sql_select.cc to intercept GROUP BY queries. Creation of group_by_handler is done after all optimizations to allow storage engine to benefit of an optimized WHERE clause and suggested indexes to use. - Added group by handler to sequence engine and a group_by test suite as a way to test the new interface. - Intercept EXPLAIN with a message "Storage engine handles GROUP BY" libmysqld/CMakeLists.txt: Added new group_by_handler files sql/CMakeLists.txt: Added new group_by_handler files sql/group_by_handler.cc: Implementation of group_by_handler functions sql/group_by_handler.h: Definition of group_by_handler class sql/handler.h: Added handlerton function to create a group_by_handler, if the storage engine can intercept the query. sql/item_cmpfunc.cc: Allow one to evaluate item_equal any time. sql/sql_select.cc: Added code to intercept GROUP BY queries - If all tables are from the same storage engine and the query is using sum functions, call create_group_by() to check if the storage engine can intercept the query. - If yes: - create a temporary table to hold a GROUP_BY row or result - In do_select() intercept normal query execution by instead calling the group_by_handler to get the result - Intercept EXPLAIN sql/sql_select.h: Added handling of group_by_handler Added caching of the original join tab (needed for cleanup after group_by handler) storage/sequence/mysql-test/sequence/group_by.result: Test group_by_handler interface storage/sequence/mysql-test/sequence/group_by.test: Test group_by_handler interface storage/sequence/sequence.cc: Added simple group_by_engine for handling COUNT(*) and SUM(primary_key). This was done as a test of the group_by_handler interface
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r--sql/sql_select.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 57c66bae8e2..4e77d5b6008 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1011,6 +1011,7 @@ public:
*/
uint top_join_tab_count;
uint send_group_parts;
+ uint do_select_call_count;
/*
True if the query has GROUP BY.
(that is, if group_by != NULL. when DISTINCT is converted into GROUP BY, it
@@ -1080,6 +1081,12 @@ public:
/* Finally picked QEP. This is result of join optimization */
POSITION *best_positions;
+ /* points to a storage engine if all tables comes from the storage engine */
+ handlerton *one_storage_engine;
+ group_by_handler *storage_handler_for_group_by;
+ JOIN_TAB *original_join_tab;
+ uint original_table_count;
+
/******* Join optimization state members start *******/
/*
pointer - we're doing optimization for a semi-join materialization nest.
@@ -1378,6 +1385,10 @@ public:
group_optimized_away= 0;
no_rows_in_result_called= 0;
positions= best_positions= 0;
+ one_storage_engine= 0;
+ storage_handler_for_group_by= 0;
+ original_join_tab= 0;
+ do_select_call_count= 0;
explain= NULL;