gpt4 book ai didi

MySQL SELECT NOT IN 从 30K 行快速

转载 作者:行者123 更新时间:2023-11-29 06:03:19 25 4
gpt4 key购买 nike

My DB table name_info has it 30K row & terms table 60K row, When select not in table, server CPU goes up.

我怎样才能最好地编写快速选择 1 行的查询?

SELECT slug FROM terms WHERE slug LIKE 'nm%' AND slug NOT IN 
(SELECT imdb_id FROM name_info) LIMIT 1

最佳答案

确保查询中使用的列已编入索引。

SELECT `slug`
FROM `terms`
LEFT JOIN `name_info`
ON `slug` = `imdb_id`
WHERE slug LIKE 'nm%'
AND `imdb_id` IS NULL
LIMIT 0,1;

关于MySQL SELECT NOT IN 从 30K 行快速,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43339228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com