From 1182b14a0a2e6d06a14849d0d395141164daa46b Mon Sep 17 00:00:00 2001 From: Arne Luenser Date: Mon, 27 Jan 2025 13:05:34 +0100 Subject: [PATCH] feat: index hint for CRDB when deleting identity credentials --- persistence/sql/identity/persister_identity.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/persistence/sql/identity/persister_identity.go b/persistence/sql/identity/persister_identity.go index 990f97a550ba..eada3ec3e789 100644 --- a/persistence/sql/identity/persister_identity.go +++ b/persistence/sql/identity/persister_identity.go @@ -1085,11 +1085,13 @@ func (p *IdentityPersister) UpdateIdentity(ctx context.Context, i *identity.Iden return err } - // #nosec G201 -- TableName is static + tableName := "identity_credentials" + if tx.Dialect.Name() == "cockroach" { + tableName += "@identity_credentials_identity_id_idx" + } if err := tx.RawQuery( - fmt.Sprintf( - `DELETE FROM %s WHERE identity_id = ? AND nid = ?`, - new(identity.Credentials).TableName(ctx)), + // #nosec G201 -- TableName is static + fmt.Sprintf(`DELETE FROM %s WHERE identity_id = ? AND nid = ?`, tableName), i.ID, p.NetworkID(ctx)).Exec(); err != nil { return sqlcon.HandleError(err) }