add_clean_index( string $table, string $index ): true
Adds an index to a specified table.
Parameters
-
$table
string Required -
Database table name.
-
$index
string Required -
Database table index column.
Return
true True, when done with execution.
Source
File: wp-admin/includes/upgrade.php
.
View all references
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. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
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.