Skip to content

Commit 5598d6b

Browse files
Avoid wildcard search if unnecessary
As a performance improvement, avoid the `LIKE` SQL query if the patient name query does not contain any wildcards.
1 parent b30ef69 commit 5598d6b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/services/storage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ def find_worklist_items(
405405
if patient_name:
406406
# Convert DICOM wildcards (* → %, ? → _) to SQL LIKE syntax.
407407
sql_pattern = patient_name.replace("*", "%").replace("?", "_")
408-
where_clauses.append("UPPER(patient_name) LIKE UPPER(?)")
408+
if sql_pattern == patient_name: # no wildcards were present
409+
where_clauses.append("UPPER(patient_name) = UPPER(?)")
410+
else:
411+
where_clauses.append("UPPER(patient_name) LIKE UPPER(?)")
409412
params.append(sql_pattern)
410413

411414
if where_clauses:

0 commit comments

Comments
 (0)