List:Internals« Previous MessageNext Message »
From:Marko Mäkelä Date:July 1 2005 12:20pm
Subject:bk commit into 5.0 tree (marko:1.1995)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of marko. When marko 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
  1.1995 05/07/01 13:20:16 marko@stripped +1 -0
  InnoDB: Optimize [and clarify] a condition in build_template()

  sql/ha_innodb.cc
    1.222 05/07/01 13:20:06 marko@stripped +32 -9
    build_template(): Optimize (and make more readable) the conditions
    for skipping or including a field.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	marko
# Host:	hundin.mysql.fi
# Root:	/home/marko/mysql-5.0-current

--- 1.221/sql/ha_innodb.cc	Tue Jun 21 11:49:46 2005
+++ 1.222/sql/ha_innodb.cc	Fri Jul  1 13:20:06 2005
@@ -2955,21 +2955,44 @@
 		templ = prebuilt->mysql_template + n_requested_fields;
 		field = table->field[i];
 
-                ibool index_contains_field=
-                  dict_index_contains_col_or_prefix(index, i);
+		if (UNIV_LIKELY(templ_type == ROW_MYSQL_REC_FIELDS)) {
+			/* Decide which columns we should fetch
+			and which we can skip. */
+			register const ibool	index_contains_field =
+				dict_index_contains_col_or_prefix(index, i);
 
-		if (templ_type == ROW_MYSQL_REC_FIELDS && 
-                    ((prebuilt->read_just_key && !index_contains_field) ||
-		     (!(fetch_all_in_key && index_contains_field) &&
-		      !(fetch_primary_key_cols &&
-			dict_table_col_in_clustered_key(index->table, i)) &&
-		      thd->query_id != field->query_id))) {
+			if (!index_contains_field && prebuilt->read_just_key) {
+				/* If this is a 'key read', we do not need
+				columns that are not in the key */
+
+				goto skip_field;
+			}
+
+			if (index_contains_field && fetch_all_in_key) {
+				/* This field is needed in the query */
+
+				goto include_field;
+			}
+
+			if (thd->query_id == field->query_id) {
+				/* This field is needed in the query */
+
+				goto include_field;
+			}
+
+			if (fetch_primary_key_cols
+			    && dict_table_col_in_clustered_key(index->table,
+									i)) {
+				/* This field is needed in the query */
+
+				goto include_field;
+			}
 
 			/* This field is not needed in the query, skip it */
 
 			goto skip_field;
 		}
-
+include_field:
 		n_requested_fields++;
 
 		templ->col_no = i;
Thread
bk commit into 5.0 tree (marko:1.1995)Marko Mäkelä1 Jul