Adds an index to a specified table.
Parameters
$tablestringrequired- Database table name.
$indexstringrequired- Database table index column.
Source
function add_clean_index( $table, $index ) {
global $wpdb;
drop_index( $table, $index );
$wpdb->query( "ALTER TABLE `$table` ADD INDEX ( `$index` )" );
return true;
}
Changelog
| Version | Description |
|---|---|
| 1.0.1 | Introduced. |
Sometimes after a table has been created in a database, we find that it is advantageous to add an index to that table to speed up queries involving this table.