Solved

Which table first?

Posted on 1998-03-18
1
391 Views
Last Modified: 2010-05-18
I have two tables; the first table has 2 million records, where 1 column is called DEA_NO, which 1 million records has DEA_NO = NULL.  The table has a non-clustered index on this column.  The second table has about 140 records, and a column called DEA_NO (same type and size as in table one).  Using the following query:

Update Table_Two
Set A.ME_Number = Table_One.ME_Number
From Table_Two A, Table_One(3)
Where A.DEA_NO = Table_One.DEA_NO

with ShowPlan ON, Sybase shows that it wants to use Table_One first (with the forced index) matching Table_Two with a table scan.  Unfortunately, this actually works like a table scan on Table_One anyway, only we are traversing the table in DEA_NO order.  Why does Sybase insist on using Table_One first, instead of moving through the 140 records in Table_Two, looking up the records (which are indexed) in Table_One.  

Thanks.

Brent
0
Comment
Question by:bknouse
1 Comment
 
LVL 2

Accepted Solution

by:
jbiswas earned 50 total points
ID: 1098378
Looks like you are working with Doctor profiles for a pharmaceutical application. Firstly it would help to know what sybase software you are using. If you are SQL Anywhere, you basically can't do much, except maybe try and reindex both the ME# and DEA# fields in the two tables.

If you are using Sybase then what version of sybase are you using. Syatem 10 was notorious for doing what you are observing , but I haven't seen anything like this with system 11. Either way, you can drop and recreate the index (on both ME# and DEA#) and see if anything is different. If that doesn't work, try using the "forceindex" clause. I haven't used it in a while, so please look up forceindex in the sybooks documentation. It tells you how to force the query optimizer to use your index.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sybase sql anywhere unload database 3 804
Crystal Reports VB6 11 1,035
SyBase SQL Query 7 153
Could you give me a guidance on how to be actualized in Power Builder? 3 54
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now