troubleshooting Question

SQL query very slow in Sybase but not in SQL Server

Avatar of msnyder8
msnyder8 asked on
Databases
8 Comments1 Solution544 ViewsLast Modified:
The following query runs at least 30 minutes in Sybase Adaptive Server Anywhere 9 (got tired of waiting), but only takes a few seconds in SQL Server 2000.

SELECT n.names_id, n.first_name, n.last_long_name, n."address", n.address_2, n.company
FROM names n WHERE EXISTS (SELECT 1 FROM names n2
WHERE IsNull(n.last_long_name,'') = IsNull(n2.last_long_name,'')
AND IsNull(n.first_name,'') = IsNull(n2.first_name,'')
AND n.names_id <> n2.names_id)
ORDER BY n.last_long_name, n.first_name

I am querying a table of names with 162,000 records.  I have rewritten the query using a join instead of the subquery, but either way it takes forever.

Any help is appreciated.
ASKER CERTIFIED SOLUTION
Computer101

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros