add_clean_index( string $table, string $index ): true
将索引添加到指定的表。
参数
$table string
必填
数据库表名。
$index string
必需
数据库表索引列。
返回
true
执行完毕后为true
。
用户贡献的笔记
有时在数据库中创建表后,我们发现向该表添加索引以加快涉及该表的查询是有利的。
function wpdocs_mwb_make_fetch_fast() {
global $wpdb;
// Add some Clean up indices
add_clean_index( $wpdb->posts, 'post_name' );
add_clean_index( $wpdb->categories, 'category_nicename' );
add_clean_index( $wpdb->comments, 'comment_approved' );
add_clean_index( $wpdb->posts, 'post_status' );
}
评论已关闭