【发布时间】:2021-08-02 20:14:42
【问题描述】:
在优化的 WordPress 数据库上运行简单的SELECT 需要 20 秒,因为它返回 62,000 条记录。有人对如何改进这些时间有任何建议吗?
我的代码:
global $wpdb;
$entries_sql = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '%s' AND meta_value='%s'", 'sht_ranking_id', $ranking_id);
$entry_ids = $wpdb->get_results($entries_sql, ARRAY_N);
(我也尝试过使用 PHPMyAdmin 运行原始 SQL,但速度并不快。)
【问题讨论】:
标签: mysql wordpress performance query-optimization