Significant String use/duplication associated with subselect fetch

Description

Finding that the use of {{@Fetch(FetchMode.SUBSELECT)}] results in a significant level of string duplication for SQL and SQL fragments. When loading large datasets and/or higher numbers of associations with multiple associations using SUBSELECT the memory can accumulate significantly (e.g. on the order of multiple GB for string space associated with the duplicate SQL fragments alone). The testcase has a rather small set of strings for only 600 simple entities.

An OQL query (in Eclipse MAT) like the below was used to obtain the strings/fragments related to queries when running in the debugger with a breakpoint at commit (e.g. in the attached test).

Then right clicking duplicated strings and using Merge Shortest Paths to GC Roots -> Exclude all phantom/weak/soft etc. references shows that the strings seem to be retained in a hierarchy like the below:

In the attached test is a spreadsheet with some comparison for the string usage between SELECT and SUBSELECT fetch (see the Employee entity for the two associations). Note that the test is quite minimal in terms of usage, adding associations, etc. magnifies the duplication.

It seems that each instance of SubselectFetches copies the original query

Environment

None

Assignee

Gail Badner

Reporter

Stephen Fikes

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure