MAIN_TABLE中有超过1亿条记录; SECURITY_TABLE中有超过2.5亿条记录。我试图从MAIN_TABLE中检索符合过滤条件的对象,并且当前用户也可以访问(访问记录存储在security_table中)。我使用类似以下内容进行查询:短语SQL语句
01 select col1, col2, col3 from main_table
02 where (col4 like '%something%'
03 or col4 like '%something else%'
04 or col4 like "%some other thing%')
05 AND
06 col1 in (select st_col1 from security_table
07 where st_id in (
08 select col1 from main_table
09 where (col4 like '%something%'
10 or col4 like '%something else%'
11 or col4 like "%some other thing%'
12 )
13 )
14 AND
15 st_user_id = current_user_id
16)
如果我必须在线路过滤标准2-4(标准A)五场比赛,将过滤条件在9-11行(标准B)重新扫描MAIN_TABLE中的全部1亿条记录,或仅包含2-4行返回的5条记录?
+1 RDBMS将决定如何应用您的子句。 – Matthew