Solved

Missing Join Predicate

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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