我有一个类似于以下内容的查询:
select <field list>
from <table list>
where <join conditions>
and <condition list>
and PrimaryKey in (select PrimaryKey from <table list>
where <join list>
and <condition list>)
and PrimaryKey not in (select PrimaryKey from <table list>
where <join list>
and <condition list>)
Run Code Online (Sandbox Code Playgroud)
子选择查询都有自己的多个子选择查询,我没有显示,以免混淆语句.
我的团队中的一位开发人员认为视图会更好.我不同意SQL语句使用程序传入的变量(基于用户的登录ID).
是否应该使用视图与使用SQL语句时有什么硬性规定?在针对常规表和针对视图运行SQL语句时会出现什么样的性能增益问题.(请注意,所有联接/ where条件都是针对索引列的,因此这不应该是一个问题.)
编辑澄清......
这是我正在使用的查询:
select obj_id
from object
where obj_id in(
(select distinct(sec_id)
from security
where sec_type_id = 494
and (
(sec_usergroup_id = 3278
and sec_usergroup_type_id = 230)
or
(sec_usergroup_id in (select ug_gi_id
from user_group
where …Run Code Online (Sandbox Code Playgroud)