public static function create_index(){
$indexs = [
['cid' => -1],
['market_person' => -1],
['created_at_date' => -1,'market_person' => -1],
];
$options = ['background' => true, 'socketTimeoutMS' => 300000];
foreach($indexs as $columns){
self::getCollection()->createIndex($columns,$options);
}
}
$indexs里面的每一个数组就是一个索引,
$options 里面的background代表后台执行的意思,因为添加索引,如果不加这个选项,如果表很大,要执行几十分钟,那么库会被加锁。