我在我的项目中创建了复杂的查询构建器,并且在测试期间偶然发现了奇怪的问题:具有相同计划的相同查询在不同客户端上产生不同的结果:cx_Oracle忽略order by子句,而Oracle SQLDeveloper Studio正确处理查询,但在这两种情况下在两个计划中按目前排序.
有问题的查询是:
select *
from
(
select
a.*,
ROWNUM tmp__rnum
from
(
select base.*
from
(
select id
from
(
(
select
profile_id as id,
surname as sort__col
from names
)
/* here usually are several other subqueries chained by unions */
)
group by id
order by min(sort__col) asc
) tmp
left join (profiles) base
on tmp.id = base.id
where exists
(
select t.object_id
from object_rights t
where
t.object_id = base.id
and t.subject_id = :a__subject_id
and …Run Code Online (Sandbox Code Playgroud)