Re: ORA01467: sort key too long error

Saad

One of the reasons for large sort keys can be poor application design and/or
poor query design. For example, if you find yourself having to use SELECT
DISTINCT with a large number of columns. It may be (relationally) possible
to recast the query in such a way as to avoid the problem. To take a trivial
example, you may find that the query is something like:

select distinct d.name
from dept d, emp e
where e.deptno = d.deptno

The query above uses a sort distinct, whereas:

select d.name
from dept d
where exists (
select 1 from emp e
where e.deptno = d.deptno
)

doesn't need to have a sort.

Obviously your sort key is much more than a single column - but the same
principal may apply

HTH

Nigel

Other related posts: