From: Roy Lyseng Date: September 22 2010 11:12am Subject: bzr commit into mysql-next-mr-bugfixing branch (roy.lyseng:3247) List-Archive: http://lists.mysql.com/commits/118788 Message-Id: <20100922111249.1F99E1EC@tyr67.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5365875937800147315==" --===============5365875937800147315== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/rl136806/mysql/repo/mysql-review/ based on revid:jorgen.loland@stripped 3247 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:12:21 +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:12:21 +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 --===============5365875937800147315== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/roy.lyseng@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: roy.lyseng@stripped # target_branch: file:///home/rl136806/mysql/repo/mysql-review/ # testament_sha1: 996da48bdf719ba498241d1d369faf5424dae54e # timestamp: 2010-09-22 13:12:49 +0200 # base_revision_id: jorgen.loland@stripped\ # 4fe3hk8ejj6vml78 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWXQuiCgAAmzfgFQQcH///3a3 3gq////wUAYMTwAGjUSQFG2YSiImymnpGTRphATU9oiAA0ybUBkHqHGTJkxGJgBMmCZADRhGAIYB KI0FNE2mU0yaAAAaAAAaGj1GhxkyZMRiYATJgmQA0YRgCGASSBGjQJoFHkTaJ6j1Mp6Ykeo9TQ0A aeURCWFVGn3xD2/bp3/JX10FRuMUDFrxeMuGaTTqhNNiQT0sj3fE3RtW225Qo0SWEQGETzH/pXSa pgNwVVRVKvYPxrSla1Kr4X4b8S/KTNJrXvXSZrnExiL1/IsppQrNkZUwPHTyTm0yPzC2QIqVSMJY QgKLnSqhEeSleZHY8V2IMHYVZ+F9W+wpYW9V6NVEMpJsGdgqaTjSR/go+JIRj0lPJBPIzBq1ipQA 2ga9zSTY5iloaYly9GVQlCe9CcFwTQZDnQLyREF763daHIT8mQrQejFgyz53RjIOet0LhgXIOwLV ZNxAi50Llcyi0pgV8IoDqYMSVhwrAoBAi4D2F2RZ7rZQdjgvLkEXGYf7dkPuKwaWZ2fCPiGFbXHi Vm0a8pscGJbqqHNRC2BsYAkFwDAa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