Skip to content

Conversation

@sbrossie
Copy link
Member

@sbrossie sbrossie commented Sep 10, 2024

This PR attempts to address some performance issues that were reported when a large number of entries have been inserted in the catalog tables to override some usage sections.

Additional tests have been written to minimize potential effect for the change on existing data but certainly not bullet proof. Details is in each commits.

⚠️ The code has not been tested against large deployment so it is a best effort based on reports.

…TargetTierDefinition

Previous implementation relied on sql `concat` method which seem to prevent sql engine from using an index.

The new implementation simplifies the logic by looking at the first block only (with the assumption) and all blocks
within a tier should provide the matching tier (if this were not the case previous impl would anyway fail to return the entry).
…TargetUsageDefinition

Previous implementation relied on sql `concat` method which seem to prevent sql engine from using an index. This is similar to what we did in 5eaef9b

Note however that previous CatalogOverrideUsageTierSqlDao#getTargetUsageDefinition would return a list of `Long` indicating that we could have different tiers across different usage sections. I can't seem to understand the use case and how the code was handling this anyways, so after much thinking and additional tests, i removed this (what to seem unused)complexity.
…tTargetPhaseDefinition

Previous implementation relied on sql `concat` method which seem to prevent sql engine from using an index. This is exactlyvsimilar to what we did in 6f3e16a incl the change of signature from a list of Long to a Long.
…and 5eaef9b

Add a 'i' parameter (e.g. tierNumber) to handle case when there is an array where first entry is null.
…TargetPlanDefinition

Previous implementation relied on sql `concat` method which seem to prevent sql engine from using an index. This is exactlyvsimilar to what we did in 6f3e16a incl the change of signature from a list of Long to a Long.
@sbrossie sbrossie changed the title Catalog usage override Revisit catalog usage override impl Sep 10, 2024
@sbrossie sbrossie marked this pull request as ready for review September 17, 2024 03:52
@sbrossie sbrossie requested a review from pierre September 17, 2024 03:53
final CatalogOverridePlanPhaseSqlDao sqlDao = inTransactionHandle.attach(CatalogOverridePlanPhaseSqlDao.class);

final List<String> keys = new ArrayList<String>();
if (overridePhaseDefinitionModelDaos.length == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: not required (loop wouldn't have any element to go through).

final CatalogOverridePhaseUsageSqlDao sqlDao = inTransactionHandle.attach(CatalogOverridePhaseUsageSqlDao.class);

final List<String> keys = new ArrayList<String>();
if (overrideUsageDefinitionModelDaos.length == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: same remark.

final CatalogOverrideUsageTierSqlDao sqlDao = inTransactionHandle.attach(CatalogOverrideUsageTierSqlDao.class);

final List<String> keys = new ArrayList<String>();
if (overrideTierDefinitionModelDaos.length == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: same remark.

final CatalogOverrideTierBlockSqlDao sqlDao = inTransactionHandle.attach(CatalogOverrideTierBlockSqlDao.class);

final List<String> keys = new ArrayList<String>();
if (overrideBlockDefinitionModelDaos.length == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: same remark.

@sbrossie sbrossie merged commit 370aace into master Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants