Solved

Missing Join Predicate

Posted on 2011-09-28
4
861 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

16 Experts available now in Live!

Get 1:1 Help Now