summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-06-09 20:22:03 +0300
committerMichael Widenius <monty@askmonty.org>2011-06-09 20:22:03 +0300
commit97e834e1517ade2779da5bc4e5fae0d000c3864b (patch)
tree165da696421477610f4d54fc1ebd6dfe222b2acd /sql
parent3600e6b81cc52d34205c6ec44c0a3fd78f1e881b (diff)
downloadmariadb-git-97e834e1517ade2779da5bc4e5fae0d000c3864b.tar.gz
Use dynamic row format when creating temporary tables without sumary fields.
The reason for this is that BLOCK_RECORD format is not good when there is a lot of duplicated keys as it first writes the data (to get the row position) and then writes the key (and thus checks for duplicates).
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 287f08bad44..9d2298e4675 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -11009,10 +11009,21 @@ static bool create_internal_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
OPTION_BIG_TABLES)
create_info.data_file_length= ~(ulonglong) 0;
+ /*
+ The logic for choosing the record format:
+ The STATIC_RECORD format is the fastest one, because it's so simple,
+ so we use this by default for short rows.
+ BLOCK_RECORD caches both row and data, so this is generally faster than
+ DYNAMIC_RECORD. The one exception is when we write to tmp table
+ (no updates == no sum fields) in which case BLOCK RECORD is slower as
+ we first write the row, then check for key conflicts and then we have to
+ delete the row.
+ */
if ((error= maria_create(share->table_name.str,
- share->reclength < 64 &&
- !share->blob_fields ? STATIC_RECORD :
- BLOCK_RECORD,
+ (share->reclength < 64 &&
+ !share->blob_fields ? STATIC_RECORD :
+ !param->sum_func_count ? DYNAMIC_RECORD :
+ BLOCK_RECORD),
share->keys, &keydef,
(uint) (param->recinfo-param->start_recinfo),
param->start_recinfo,