Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Which table first?

Posted on 1998-03-18
1
Medium Priority
?
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
jbiswas earned 200 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

660 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