Bug 295589 - RFE: Prevent unnecessary JOINs
Summary: RFE: Prevent unnecessary JOINs
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-19 09:14 EST by Markus Karg CLA
Modified: 2022-06-09 10:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Karg CLA 2009-11-19 09:14:29 EST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)
Build Identifier: N/A

This is a request for enhancement, but not a bug report.

I did a small N:M master-detail test using TopLink and noticed that the SQL SELECT issued to get the referenced detail (M) entities unnecessarily does a self-JOIN:

SELECT t1.vid_qmerkmal, t1.id_nest, t1.vid_auftrag FROM t_atmk t0, t_atmk t1 WHERE ((t0.vid_auftrag = ?) AND ((t1.vid_auftrag = t0.vid_auftrag) AND ((t1.id_nest = t0.id_nest) AND (t1.vid_qmerkmal = t0.vid_qmerkmal))))

As you can see, it does a FROM X, X which just makes things more complex but brings no benefit.

Since obviously a an unnecessary JOIN (even an unnecessary self-JOIN) in virtually all cases needs more time to get resolved than a plain "FROM Table", the unnecessary JOIN should get removed in favour of a simple SELECT x FROM Table WHERE ...


Reproducible: Always

Steps to Reproduce:
Maybe only happens when using @EmbeddedId with compound key in the detail (M) entity?
Comment 1 James Sutherland CLA 2010-08-09 14:18:55 EDT
Can't see why EclipseLink would generate that SQL, unless incorrectly mapped or an odd query.

Refer to any of the examples or tests that define m-m that do not generate this.

Please include your mappings and JPQL query code to get the SQL.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:25:09 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink