Skip to content

O3-5697: Add indexes to queue_entry for queue_id, patient_id & started_at/ended_at - #116

Merged
NethmiRodrigo merged 3 commits into
openmrs:mainfrom
UjjawalPrabhat:O3-5697-index-queue-entry
Aug 31, 2026
Merged

O3-5697: Add indexes to queue_entry for queue_id, patient_id & started_at/ended_at#116
NethmiRodrigo merged 3 commits into
openmrs:mainfrom
UjjawalPrabhat:O3-5697-index-queue-entry

Conversation

@UjjawalPrabhat

@UjjawalPrabhat UjjawalPrabhat commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

The queue_entry table of Service Queues has no indexes on the columns those queries filter by (queue_id, patient_id, started_at, ended_at). Every query therefore scans the entire table.

On a fresh demo install with a handful of patients this is invisible. But in a real clinic with months or years of accumulated queue history (potentially tens of thousands of rows), the queue page gets progressively slower until staff notice it taking seconds to load and by then the table is large enough that adding indexes needs careful migration planning. Indexing it now, while it's small, avoids that.

Related Issue

O3-5697

@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

@jwnasambu jwnasambu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, @UjjawalPrabhat good and focused change.

Comment thread api/src/main/resources/liquibase.xml
Comment thread api/src/main/resources/liquibase.xml Outdated

@NethmiRodrigo NethmiRodrigo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @UjjawalPrabhat! Just one more thing -

Comment thread api/src/main/resources/liquibase.xml Outdated
queue_entry_patient_id_fk already indexes patient_id, so a name-based
precondition would create a duplicate index on existing installs.
@sonarqubecloud

Copy link
Copy Markdown

@NethmiRodrigo NethmiRodrigo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @UjjawalPrabhat!

@NethmiRodrigo
NethmiRodrigo merged commit 706ca3b into openmrs:main Aug 31, 2026
9 checks passed
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