1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

WL#1687 - Optimize UNION DISTINCT ... UNION ALL (again).

HEAP: Copies the key count to a backup variable and sets the key count to zero.
That way, no HEAP function will ever try to touch any index.
Re-enabling is done by copying back the backup variable.
To avoid memory leak at table close, disable deletes all index trees.
Re-enabling must be done with empty indexes and data anyway. Otherwise,
the indexes would need to be repaired, wich HEAP is not capable of.
MyISAM: Only the key_map is cleared and set.
Re-enabling must be done with empty indexes and data. Otherwise, repair needs
to be done which will enable all keys persistently.
The former implementation disabled only non-unique keys and maked this persistent.
The new implementation additionally can disable all keys, but only without
making this persistent. Re-enabling all keys can be done without repair,
if data file and indexes are empty.
This commit is contained in:
ingo@mysql.com
2004-05-06 15:53:01 +02:00
parent 4d8235b849
commit 784c9526ec
12 changed files with 530 additions and 62 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB
/* Copyright (C) 2000-2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2556,14 +2556,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
VOID(pthread_mutex_lock(&LOCK_open));
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
VOID(pthread_mutex_unlock(&LOCK_open));
error= table->file->enable_indexes();
error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
/* COND_refresh will be signaled in close_thread_tables() */
break;
case DISABLE:
VOID(pthread_mutex_lock(&LOCK_open));
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
VOID(pthread_mutex_unlock(&LOCK_open));
error=table->file->disable_indexes(0, 1);
error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
/* COND_refresh will be signaled in close_thread_tables() */
break;
}