Skip to content

Conversation

@FranckLecuyer
Copy link
Contributor

@FranckLecuyer FranckLecuyer commented Oct 31, 2025

PR Summary

In user-admin, there is a cron job running every 5 minutes, that checks if an announcement is present, and there is no index on start_date and end_date columns in the database, so a seqscan is always done.

So, adding index on these columns avoid using a seqscan ...

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
Copy link
Contributor

@TheMaskedTurtle TheMaskedTurtle left a comment

Choose a reason for hiding this comment

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

Don't forget the annotation in the entity. Normally, you should put the annotion in the entity and then generate the changelog with liquibase.

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="lecuyerfra" id="create_start_date_index">
<createIndex indexName="announcement_start_date_index" tableName="announcement">
<column name="start_date"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to have only one index with both start_date and end_date as we query with both values everytime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
Done

Create only one index for both columns start_date and end_date

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

@FranckLecuyer FranckLecuyer merged commit 4994ab8 into main Nov 4, 2025
4 checks passed
@FranckLecuyer FranckLecuyer deleted the add_index_on_announcement_start_and_end_date branch November 4, 2025 09:54
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