#At file:///home/rl136806/mysql/repo/mysql-review/ based on revid:tor.didriksen@stripped
3248 Roy Lyseng 2010-09-22
Refactoring: Make members positions and best_positions of class JOIN
dynamically allocated instead of fixed-size arrays.
This saves approx. 20 kbyte memory during optimization and execution
for normal-sized join operations.
sql/sql_select.cc
Allocate positions and best_positions dynamically.
sql/sql_select.h
positions and best_positions (members of class JOIN) defined as
pointers instead of arrays. Made a derived class of Sql_alloc, so
operator new can be used instead of alloc().
modified:
sql/sql_select.cc
sql/sql_select.h
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-09-22 06:51:45 +0000
+++ b/sql/sql_select.cc 2010-09-22 11:37:38 +0000
@@ -4491,6 +4491,14 @@ make_join_statistics(JOIN *join, TABLE_L
if (!stat || !stat_ref || !table_vector)
DBUG_RETURN(1); // Eom /* purecov: inspected */
+ if (!(join->positions=
+ new (join->thd->mem_root) POSITION[table_count+1]))
+ DBUG_RETURN(TRUE);
+
+ if (!(join->best_positions=
+ new (join->thd->mem_root) POSITION[table_count+1]))
+ DBUG_RETURN(TRUE);
+
join->best_ref=stat_vector;
stat_end=stat+table_count;
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2010-09-06 17:56:05 +0000
+++ b/sql/sql_select.h 2010-09-22 11:37:38 +0000
@@ -1369,7 +1369,7 @@ enum_nested_loop_state sub_select_sjm(JO
advance_sj_state() for details.
*/
-typedef struct st_position
+typedef struct st_position : public Sql_alloc
{
/*
The "fanout" - number of output rows that will be produced (after
@@ -1613,7 +1613,7 @@ public:
*/
ha_rows fetch_limit;
/* Finally picked QEP. This is result of join optimization */
- POSITION best_positions[MAX_TABLES+1];
+ POSITION *best_positions;
/******* Join optimization state members start *******/
/*
@@ -1623,7 +1623,7 @@ public:
TABLE_LIST *emb_sjm_nest;
/* Current join optimization state */
- POSITION positions[MAX_TABLES+1];
+ POSITION *positions;
/*
Bitmap of nested joins embedding the position at the end of the current
Attachment: [text/bzr-bundle] bzr/roy.lyseng@oracle.com-20100922113738-lzbny6n2lwtup3tj.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-bugfixing branch (roy.lyseng:3248) | Roy Lyseng | 22 Sep |