Closed kaladay closed 4 months ago
I have been able to confirm that this works in MySQL/MariaDB.
To get MySQL/MariaDB working, I had to alter src/main/java/org/tdl/vireo/model/Organization.java
, changing:
@ElementCollection(fetch = EAGER)
private List<String> emails;
Into
@LazyCollection(LazyCollectionOption.FALSE)
@ElementCollection
private List<String> emails;
Relates #55
The test data consisted of randomly generated data with:
The submission list page took ~3.5 minutes to load the Submission Type list data. Switching to an explicit query, the submission list page took ~320 milliseconds to load the Submission Type list data.
This is an overwhelming clear improvement that shows that the use of Spring+JPA internals are highly inefficient for the Field Values and related data. For the filters, the actual model does not need to be loaded and only the value.
The use of a JDBC query is chosen after doing tests against Postgresql and H2. The use of a native query via
@Query
worked for Postgresql but H2 used clob2 and failed to convert the results into strings. Using a literal query is chosen over a JPA query because the JPA wants to understand the model structure. The Field Predicate is not loaded immediately available for JPA for the FieldValue JPA Repository.Only very basic SQL is used in the query and so there should be very little SQL compatibility risks. The biggest risk is that of the table naming structure. This structure appears to be sufficiently consistent between Postgresql and H2 in this regard.
Spring+JPA Performance:![test_data-44075_subm-1458591_fv-jpa-Screenshot_2024-04-29_09-21-09](https://github.com/TAMULib/Vireo/assets/35114839/8a01723c-fef3-4d53-afd1-5effabbb7fdd)
JDBC Performance:![test_data-44075_subm-1458591_fv-jdbc-Screenshot_2024-04-29_09-21-09](https://github.com/TAMULib/Vireo/assets/35114839/3f8880b0-0c84-432e-8a86-3da79c9a3cbc)