From 30eb0e4b7c3a01eea61a188fd3130143e4c25c43 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Wed, 23 Oct 2024 17:48:19 -0700 Subject: [PATCH] feat: optimize findCertificateByName query - to take advantage of the new DB index on the name_lowercase column [https://vmw-jira.broadcom.net/browse/TPCF-26571] --- .../cloudfoundry/credhub/repositories/CredentialRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/credentials/src/main/kotlin/org/cloudfoundry/credhub/repositories/CredentialRepository.kt b/components/credentials/src/main/kotlin/org/cloudfoundry/credhub/repositories/CredentialRepository.kt index b5e5ace91..1149ab8b9 100644 --- a/components/credentials/src/main/kotlin/org/cloudfoundry/credhub/repositories/CredentialRepository.kt +++ b/components/credentials/src/main/kotlin/org/cloudfoundry/credhub/repositories/CredentialRepository.kt @@ -36,7 +36,7 @@ interface CredentialRepository : JpaRepository { value = "select credential.uuid, credential.name, credential.name_lowercase, credential.checksum from certificate_credential " + "left join credential_version on certificate_credential.uuid = credential_version.uuid " + "join credential on credential.uuid = credential_version.credential_uuid " + - "where credential.name = ?1 limit 1 ", + "where credential.name_lowercase = lower(?1) limit 1 ", nativeQuery = true, ) fun findCertificateByName(name: String?): Credential?