Skip to content

add missing indexes#813

Merged
EtienneLt merged 8 commits into
mainfrom
add-missing-indexes
May 22, 2026
Merged

add missing indexes#813
EtienneLt merged 8 commits into
mainfrom
add-missing-indexes

Conversation

@EtienneLt
Copy link
Copy Markdown
Contributor

PR Summary

  • add indexes on foreign keys references because there are seq scan on these column

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt self-assigned this May 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Review Change Stack

Warning

Rate limit exceeded

@EtienneLt has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 37 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f1c0af5-0376-4a85-a19d-47732afac8a2

📥 Commits

Reviewing files that changed from the base of the PR and between bc95ef9 and 60c648a.

📒 Files selected for processing (3)
  • src/main/java/org/gridsuite/modification/server/entities/ModificationApplicationEntity.java
  • src/main/resources/db/changelog/changesets/changelog_20260522T132309Z.xml
  • src/main/resources/db/changelog/db.changelog-master.yaml
📝 Walkthrough

Walkthrough

Adds JPA @Table index annotations to several entities, adds a Liquibase changeset that creates four database indexes, and includes that changeset in the master changelog.

Changes

Database Indexes

Layer / File(s) Summary
JPA @Table index annotations
src/main/java/org/gridsuite/modification/server/entities/...
Entities updated to declare named indexes: voltage_level_topology_modification_id, operational_limit_group_id, id (substation), and modification_uuid; some imports changed to jakarta.persistence.*.
Batch index creation changelog
src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml
New Liquibase changeSet addMissingIndexes defines four createIndex statements for the corresponding tables/columns.
Changelog registration
src/main/resources/db/changelog/db.changelog-master.yaml
Master changelog updated with an include entry to load the new changeset file using relativeToChangelogFile: true.

Suggested reviewers:

  • SlimaneAmar
  • antoinebhs
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'add missing indexes' directly and clearly summarizes the main change in the changeset, which adds database indexes on multiple tables.
Description check ✅ Passed The description explains the purpose of adding indexes on foreign key references to address sequential scans, which directly relates to the changeset modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml`:
- Around line 4-6: Several index names in the changelog XML exceed PostgreSQL's
63-char limit and must be shortened: update the createIndex indexName attributes
for the following entries to unique names under 63 chars—replace
boolean_equipment_attribute_modification_voltage_level_topology_modification_id_idx
with boolean_eq_attr_mod_vltm_id_idx (or similar <63 chars) for table
boolean_equipment_attribute_modification; replace
converter_station_creation_rcc_points_converter_station_creation_entity_id_idx
with conv_st_creation_rcc_points_entity_id_idx for table
converter_station_creation_rcc_points; replace
converter_station_modification_rcc_points_converter_station_modification_entity_id_idx
with conv_st_mod_rcc_points_entity_id_idx for table
converter_station_modification_rcc_points; replace
create_voltage_level_topology_switch_kinds_create_voltage_level_topology_id_idx
with vlt_switch_kinds_vlt_id_idx for table
create_voltage_level_topology_switch_kinds; replace
lcc_converter_station_modification_on_side_lcc_converter_station_modification_id_idx
with lcc_conv_st_mod_on_side_id_idx for table
lcc_converter_station_modification_on_side; and replace
shunt_compensator_on_side_lcc_converter_station_creation_entity_id_idx with
shunt_comp_on_side_conv_st_creation_id_idx for table shunt_compensator_on_side;
ensure each new name is unique, under 63 chars, update any references or tests
that expect the old names, and run migrations locally to confirm no collisions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6129f709-be5e-412c-a82e-09d56fb16a79

📥 Commits

Reviewing files that changed from the base of the PR and between fc4912f and 3737b15.

📒 Files selected for processing (2)
  • src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml
  • src/main/resources/db/changelog/db.changelog-master.yaml

Comment thread src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml Outdated
EtienneLt added 3 commits May 13, 2026 13:09
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml (1)

3-16: ⚡ Quick win

Consider one changeSet per createIndex for safer deployments.

Grouping all four createIndex calls in a single changeSet means: (a) if any one fails on a target environment, none of the four are recorded as applied; (b) re-running after a fix re-attempts the already-created ones (will fail unless failOnError/preconditions are set); (c) Liquibase's auto-rollback for index creation also operates on the whole batch. Splitting into one changeSet per index gives you per-index idempotency, partial progress, and granular rollback.

Also, since these are pure index additions on existing tables, consider adding <preConditions onFail="MARK_RAN"><indexExists indexName="..."/></preConditions> per changeSet so the migration is safe to re-run across environments where the index may already have been created out-of-band.

Note: the two specific concerns on this file (redundant index on substationModification.id and the name mismatch for modification_application_modification_uuid_idx) are flagged at the entity layer where they originate — see comments on SubstationModificationEntity.java (line 21) and ModificationApplicationEntity.java (lines 28-31).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml`
around lines 3 - 16, Split the single changeSet into four separate changeSet
entries (one per createIndex) so each index
(boolean_equipment_attribute_modif_vl_topology_modif_id_idx,
limits_property_modification_operational_limit_group_id_idx,
modification_application_modification_uuid_idx, substationModification_id_idx)
is applied independently; for each new changeSet add a preConditions block like
onFail="MARK_RAN" with an indexExists check for that indexName to make the
migration safe to re-run; also correct the index name for
modification_application to match the entity-layer name and remove or omit the
substationModification_id_idx if it is a redundant index on
substationModification.id as flagged in SubstationModificationEntity.java.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/gridsuite/modification/server/entities/ModificationApplicationEntity.java`:
- Around line 28-31: The `@Index` name in ModificationApplicationEntity (the
indexes array on the class) doesn’t match the Liquibase changelog name; change
the name value for the index currently declared as
"idx_modification_application_modification_uuid" in the `@Index` annotation to
"modification_application_modification_uuid_idx" so it exactly matches the
changelog entry (or alternatively update the changelog to
"idx_modification_application_modification_uuid" if you prefer the idx_ prefix)
— locate the indexes declaration on ModificationApplicationEntity and make the
names consistent between the `@Index` (annotation) and the Liquibase changeset.

---

Nitpick comments:
In `@src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml`:
- Around line 3-16: Split the single changeSet into four separate changeSet
entries (one per createIndex) so each index
(boolean_equipment_attribute_modif_vl_topology_modif_id_idx,
limits_property_modification_operational_limit_group_id_idx,
modification_application_modification_uuid_idx, substationModification_id_idx)
is applied independently; for each new changeSet add a preConditions block like
onFail="MARK_RAN" with an indexExists check for that indexName to make the
migration safe to re-run; also correct the index name for
modification_application to match the entity-layer name and remove or omit the
substationModification_id_idx if it is a redundant index on
substationModification.id as flagged in SubstationModificationEntity.java.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26e2b90e-a961-477b-9ec7-029076029062

📥 Commits

Reviewing files that changed from the base of the PR and between 3737b15 and bc95ef9.

📒 Files selected for processing (5)
  • src/main/java/org/gridsuite/modification/server/entities/ModificationApplicationEntity.java
  • src/main/java/org/gridsuite/modification/server/entities/equipment/modification/LimitsPropertyModificationEntity.java
  • src/main/java/org/gridsuite/modification/server/entities/equipment/modification/SubstationModificationEntity.java
  • src/main/java/org/gridsuite/modification/server/entities/equipment/modification/attribute/BooleanEquipmentAttributeModificationEntity.java
  • src/main/resources/db/changelog/changesets/changelog_20260513T140000Z.xml

EtienneLt added 3 commits May 21, 2026 13:30
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@sonarqubecloud
Copy link
Copy Markdown

@EtienneLt EtienneLt merged commit 33db2f2 into main May 22, 2026
4 checks passed
@EtienneLt EtienneLt deleted the add-missing-indexes branch May 22, 2026 13:40
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.

2 participants