Solved

Missing Join Predicate

Posted on 2011-09-28
4
887 Views
Last Modified: 2012-05-12
I get a missing join predicate warning when I run a simplet single join query with a where clause on the join field.  Both tables fields are indexed.  Is this a false alarm or is there really something that can be done to fix this.  Here is a basic example:

select field1 from table1 t1 inner join table2 t2 on t1.field2 = t2.field2 where t1.field2 = 'myvalue'

It appears to be related to field2 being the join field and the criteria.
0
Comment
Question by:ws11
[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
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36717422
The query looks OK to me, other than I would specify, in the select clause, either t1.field1 or t2.field1 (depending on which table you are drawing from).

There is absolutely nothing wrong with using the same column in the FROM clause and in the WHERE clause.
0
 

Author Comment

by:ws11
ID: 36717529
I was surprised that this was an issue.  I thought this might indicate that the indexing is a problem.  One thing that is different is that in one table the width is greater for field1 than the other table.  varchar(50) to varchar(40).

They are large tables though and I don't want any random side effects.
0
 
LVL 41

Accepted Solution

by:
ralmada earned 250 total points
ID: 36717550
>>Is this a false alarm or is there really something that can be done to fix this.<<

I would say it's a false alarm, most likely a bug in the optimizer. Having said that can also try:

select t1.field1 from table1 t1 inner join table2 t2 on t1.field2 = t2.field2 and t1.field2 = 'myvalue'


Also check this link discussing the warning message on SQL 2008:
http://www.scarydba.com/2009/09/15/no-join-predicate/
0
 

Author Comment

by:ws11
ID: 36718008
Yes that took care of it by putting the criteria in the join with the exception to one and I am trying to determine why it is different.  If I use two fields to join it is fine but a single can be more frustrating in this case.  This may be due to the other indexes on one of the join tables.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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