Skip to content

Cme 206 performance#2889

Open
AntonyLeons wants to merge 8 commits into
masterfrom
CME-206-performance
Open

Cme 206 performance#2889
AntonyLeons wants to merge 8 commits into
masterfrom
CME-206-performance

Conversation

@AntonyLeons

Copy link
Copy Markdown
Contributor

Before creating a pull request make sure that:

  • commit messages are meaningful and follow good commit message guidelines
  • README and other documentation has been updated / added (if needed)
  • tests have been updated / new tests has been added (if needed)
  • the keep-helm label has been added, if the helm release should be persisted after a successful build

Please remove this line and everything above and fill the following sections:

JIRA link (if applicable)

https://tools.hmcts.net/jira/browse/CME-206

Change description

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[ ] No

}

@Override
public String buildClauseString(String operation) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replacing date(column) = ? with a half-open timestamp range keeps the predicate sargable, so Postgres can use the existing timestamp indexes.

criteria.forEach(criterion -> criterion.bindParameters(query));
}

private String buildQueryString(boolean isCountQuery, String whereClausePart, MetaData metadata) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count queries no longer build an unused sort clause, avoiding unnecessary work

@hmcts-jenkins-a-to-c hmcts-jenkins-a-to-c Bot requested a deployment to preview May 22, 2026 16:21 Abandoned
+ " AND cae.createdDate = "
+ "(select min(caeDate.createdDate) from CaseAuditEventEntity caeDate WHERE caeDate.caseDataId = :"
+ CaseAuditEventEntity.CASE_DATA_ID + ")"
+ " ORDER BY cae.createdDate ASC"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove subquery, and sort instead of using min

spring.datasource.hikari.maximum-pool-size=${DATA_STORE_DB_MAX_POOL_SIZE:16}
# WARNING: disabling Open Session in View means lazy JPA associations must be loaded/mapped inside service or
# repository transactions. Accessing lazy associations during response serialization can cause LazyInitializationException.
spring.jpa.open-in-view=false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slight;y dangerous so could remove and merge in a future pr, but good best practice change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant