Anyone got an idea how to optimise this SQL, I am trying to use it to find
the next / previous records via ADO but it is way too slow at the moment.
Perhaps there may be a better way of doing this without a UNION?

* previous record
SELECT * FROM Master WHERE ;
(Id < lcPreviousId AND LEFT(Id,1)=lcIdCheck) ;
UNION ;
SELECT * FROM Archive WHERE ;
(Id < lcPreviousId AND LEFT(Id,1)=lcIdCheck) ;
        ORDER BY Id DESC

* next record
SELECT * FROM Master WHERE ;
(Id > lcPreviousId AND LEFT(Id,1)=lcIdCheck) ;
UNION ;
SELECT * FROM Archive WHERE ;
(Id > lcPreviousId AND LEFT(Id,1)=lcIdCheck) ;
        ORDER BY Id ASC

There are already indexes on Id (both ascending and descending) and
LEFT(Id,1).

Any suggestions, other than you don't want to do that.

Cheers,
        Nick




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/!&[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to