Solved

Missing Join Predicate

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

839 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