summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-11-29 15:34:37 +0200
committerunknown <monty@hundin.mysql.fi>2001-11-29 15:34:37 +0200
commitace649189d566532a46ff110db15ccde117ce4af (patch)
tree5278a62187996e3ff76046ee3a27680bcadfc05f /sql/sql_select.cc
parent00d80ffff1da7a19489a1aaab9ba29ded55b84ad (diff)
downloadmariadb-git-ace649189d566532a46ff110db15ccde117ce4af.tar.gz
Better optimization for InnoDB and BDB tables for ORDER BY
Build-tools/Do-compile: Merge with 4.0 Docs/manual.texi: Changelog mysql-test/r/innodb.result: New tests cases for ORDER BY mysql-test/r/myisam.result: New tests cases for ORDER BY mysql-test/t/innodb.test: New tests cases for ORDER BY mysql-test/t/myisam.test: New tests cases for ORDER BY
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 774be3679a2..9456211a7cc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5199,7 +5199,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
retrieving all rows through an index.
*/
if (select_limit >= table->file->records)
- keys&= table->used_keys;
+ keys&= (table->used_keys | table->file->keys_to_use_for_scanning());
for (nr=0; keys ; keys>>=1, nr++)
{
@@ -5213,6 +5213,11 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
join_init_read_last_with_key);
table->file->index_init(nr);
tab->type=JT_NEXT; // Read with index_first(), index_next()
+ if (table->used_keys & ((key_map) 1 << nr))
+ {
+ table->key_read=1;
+ table->file->extra(HA_EXTRA_KEYREAD);
+ }
DBUG_RETURN(1);
}
}