From 46415251fe0caf6e690f955ca22c6b5d437ad92f Mon Sep 17 00:00:00 2001 From: Julian Ladisch Date: Fri, 22 Nov 2024 12:46:41 +0100 Subject: [PATCH 1/3] MODINVSTOR-1292: Add item barcode right truncation search index https://folio-org.atlassian.net/browse/MODINVSTOR-1292 Add text_pattern_ops index for item barcode to speed up right truncation searches. --- NEWS.md | 2 +- .../db_scripts/createIndexBarcodePattern.sql | 11 +++++++++++ src/main/resources/templates/db_scripts/schema.json | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql diff --git a/NEWS.md b/NEWS.md index e126c59c8..17c09c8c9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,7 +15,7 @@ * Do not return routing service points by default ([MODINVSTOR-1219](https://folio-org.atlassian.net/browse/MODINVSTOR-1219)) ### Bug fixes -* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) +* Add item barcode right truncation search index ([MODINVSTOR-1292](https://folio-org.atlassian.net/browse/MODINVSTOR-1292)) ### Tech Dept * Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) diff --git a/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql b/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql new file mode 100644 index 000000000..7edfff58d --- /dev/null +++ b/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql @@ -0,0 +1,11 @@ +<#-- + Index for item barcode right truncation used by checkin and checkout: + https://github.com/folio-org/ui-checkout/blob/v11.0.0/src/ScanItems.js#L163-L164 + https://github.com/folio-org/ui-checkin/blob/v9.2.0/src/Scan.js#L318-L319 + The existing btree index doesn’t support right truncation because barcode is + Unicode and not "C" locale, for details see + https://www.postgresql.org/docs/current/indexes-opclass.html + https://www.cybertec-postgresql.com/en/indexing-like-postgresql-oracle/ +--> +CREATE INDEX IF NOT EXISTS item_barcode_idx_pattern + ON ${myuniversity}_${mymodule}.item (lower(jsonb->>'barcode') text_pattern_ops); diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index e2c76f3e1..de5af910a 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -1232,6 +1232,11 @@ "run": "after", "snippetPath": "publication-period/migratePublicationPeriod.sql", "fromModuleVersion": "28.0.0" + }, + { + "run": "after", + "snippetPath": "createIndexBarcodePattern.sql", + "fromModuleVersion": "28.0.2" } ] } From 8273672c324e926e36441c3eddacb4d9398cc701 Mon Sep 17 00:00:00 2001 From: Julian Ladisch Date: Thu, 28 Nov 2024 12:46:46 +0100 Subject: [PATCH 2/3] Remove documentation from .sql file, it exists in PR and Jira --- .../templates/db_scripts/createIndexBarcodePattern.sql | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql b/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql index 7edfff58d..36e7ab736 100644 --- a/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql +++ b/src/main/resources/templates/db_scripts/createIndexBarcodePattern.sql @@ -1,11 +1,2 @@ -<#-- - Index for item barcode right truncation used by checkin and checkout: - https://github.com/folio-org/ui-checkout/blob/v11.0.0/src/ScanItems.js#L163-L164 - https://github.com/folio-org/ui-checkin/blob/v9.2.0/src/Scan.js#L318-L319 - The existing btree index doesn’t support right truncation because barcode is - Unicode and not "C" locale, for details see - https://www.postgresql.org/docs/current/indexes-opclass.html - https://www.cybertec-postgresql.com/en/indexing-like-postgresql-oracle/ ---> CREATE INDEX IF NOT EXISTS item_barcode_idx_pattern ON ${myuniversity}_${mymodule}.item (lower(jsonb->>'barcode') text_pattern_ops); From b0e3016984c99c1f1ea5ed02c8d0bb6229ab1727 Mon Sep 17 00:00:00 2001 From: Julian Ladisch Date: Wed, 4 Dec 2024 19:22:54 +0100 Subject: [PATCH 3/3] next patch version is 28.0.3 --- src/main/resources/templates/db_scripts/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index de5af910a..12b5a4ff6 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -1236,7 +1236,7 @@ { "run": "after", "snippetPath": "createIndexBarcodePattern.sql", - "fromModuleVersion": "28.0.2" + "fromModuleVersion": "28.0.3" } ] }