Hi there!
Got a performance problem with entity and query cache. You can reproduce it in attached sample-sales-cuba7 project (cache-issue.zip 1.2 MB)
Basically this is project with enabled entity cache (Order, OrderLine) and query cache.
Test case.
0. Enable eclipselink.sql logger
- Open orders screen
- Click “Cached query” button
- After 2 (?) clicks no more SALES_ORDER_LINE queries appear in the log. That’s okay, we’ve loaded orders and lines so far.
- Click “Non cached query” button. It loads from DB - okay.
- Click “Cached query” again.
Actual result. It loads order lines from the DB. And this is something I don’t understand? Why it loads orders and lines? They were cached before.
Example of the order lines loaded at step 5:
2022-08-26 15:56:15.504 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 1459080584> [0 ms] spent
2022-08-26 15:56:15.507 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 919723986> SELECT ID, CREATE_TS, CREATED_BY, DELETE_TS, DELETED_BY, QUANTITY, UPDATE_TS, UPDATED_BY, VERSION, ORDER_ID, PRODUCT_ID FROM SALES_ORDER_LINE WHERE ((ORDER_ID = ?) AND (DELETE_TS IS NULL))
bind => [a64649a9-a646-49a9-8f15-cf798f15cf79]
2022-08-26 15:56:15.508 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 919723986> [1 ms] spent
2022-08-26 15:56:15.510 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 907774191> SELECT ID, CREATE_TS, CREATED_BY, DELETE_TS, DELETED_BY, QUANTITY, UPDATE_TS, UPDATED_BY, VERSION, ORDER_ID, PRODUCT_ID FROM SALES_ORDER_LINE WHERE ((ORDER_ID = ?) AND (DELETE_TS IS NULL))
bind => [ec864774-ec86-4774-d935-2ce5d9352ce5]
2022-08-26 15:56:15.511 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 907774191> [1 ms] spent
2022-08-26 15:56:15.513 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 1246617453> SELECT ID, CREATE_TS, CREATED_BY, DELETE_TS, DELETED_BY, QUANTITY, UPDATE_TS, UPDATED_BY, VERSION, ORDER_ID, PRODUCT_ID FROM SALES_ORDER_LINE WHERE ((ORDER_ID = ?) AND (DELETE_TS IS NULL))
bind => [f12a4193-f12a-4193-c83d-2a46c83d2a46]
2022-08-26 15:56:15.514 DEBUG [http-nio-8080-exec-19/app-core/admin] eclipselink.sql - <t 1661478782, conn 1246617453> [1 ms] spent
It reproduced both in hsql and postgres.