select a.* from (select * from ducc.job order by stateIndex asc, id
desc) a where id < 117000
Why is this query written like this, as opposed to, say:
select * from ducc.job order by stateIndex asc, id desc
where id < 117000
Do you get a different query plan / run time if you use a
single top-level query and eliminate the sub-query?
I think the optimizer does a pretty good job in general of
optimizing sub queries but maybe the presence of the ORDER BY
in the sub query is making it hard for the query optimizer
to perform the query efficiently?
thanks,
bryan