My Oracle Support Banner

JPA Performance When Using ONE TO MANY with More Than One Table (Doc ID 1198504.1)

Last updated on JUNE 26, 2021

Applies to:

Oracle WebLogic Server - Version 10.3 to 10.3.3
Information in this document applies to any platform.

Symptoms

Usecase
Performance issues seen when using tables with one to many relationship

The performance issue is seen when you query find by primary key of '<TABLE_1>' Entity.

"entityManager.find(<TABLE_1>.class, ID);"

SQL output in WLS 10.3
===================
1.) SELECT t0.<FIELD1>, t1.<TABLE_1_ID>, t1.ID, t1.<FIELD2>
FROM <TABLE_1> t0, <TABLE_4> t1
WHERE t0.ID = ? AND t0.ID = t1.<TABLE_1_ID>(+)
ORDER BY t1.<TABLE_1_ID> ASC, 1003, 1007)>

2.) SELECT t0.ID, t0.<FIELD3> FROM <TABLE_2> t0 WHERE t0.<TABLE_1_ID> = ?,
1003, 1007)>

SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_2> t0, <TABLE_1> t1 WHERE t0.ID
= ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>

3.) SELECT t0.ID, t0.<FIELD4>, t0.<FIELD5> FROM <TABLE_3> t0 WHERE
t0.<TABLE_1_ID> = ?, 1003, 1007)>

SELECT t1.ID, t1.<FIELD1> FROM <TABLE_3> t0, <TABLE_1> t1
WHERE t0.ID = ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_3> t0, <TABLE_1> t1
WHERE t0.ID = ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_3> t0, <TABLE_1> t1
WHERE t0.ID = ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_3> t0, <TABLE_1> t1
WHERE t0.ID = ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>
SELECT t1.ID, t1.<FIELD1> FROM <TABLE_3> t0, <TABLE_1> t1
WHERE t0.ID = ? AND t0.<TABLE_1_ID> = t1.ID, 1003, 1007)>

The same usecase on WLS 10.0 gives the below SQL output:
============================================
1.)SELECT t0.<FIELD1>, t1.<TABLE_1_ID>, t1.ID, t1.<FIELD2>, t2.ID, t2.<FIELD1>
FROM <TABLE_1> t0, <TABLE_4> t1, <TABLE_1> t2 WHERE t0.ID = ?
AND t0.ID = t1.<TABLE_1_ID>(+) AND t1.<TABLE_1_ID> = t2.ID(+) ORDER BY
t1.<TABLE_1_ID> ASC)>
2.)SELECT t0.ID, t0.<FIELD3>, t1.ID, t1.<FIELD1> FROM <TABLE_2> t0,
<TABLE_1> t1 WHERE t0.<TABLE_1_ID> = ? AND t0.<TABLE_1_ID> = t1.ID(+))>
3.)SELECT t0.ID, t0.<FIELD4>, t1.ID, t1.<FIELD1>, t0.<FIELD5> FROM
<TABLE_3> t0, <TABLE_1> t1 WHERE t0.<TABLE_1_ID>
= ? AND t0.<TABLE_1_ID> = t1.ID(+))>

So in WLS 10.3 the SQL entries are not joining instead it increases the number of queries.

Changes

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.