Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
perf(payment-methods): optimize for payment method latency (#13505)
Kashiffc49ced8d018
diff --git a/crates/common_utils/Cargo.toml b/crates/common_utils/Cargo.tomlindex 5317a89d10..9e08b6dfe8 100644--- a/crates/common_utils/Cargo.toml+++ b/crates/common_utils/Cargo.toml@@ -13,6 +13,7 @@ keymanager = ["dep:router_env"]keymanager_mtls = ["reqwest/rustls-tls"]encryption_service = ["dep:router_env"]km_forward_x_request_id = ["dep:router_env", "router_env/actix_web"]+ext_services_latency = ["dep:router_env"]signals = ["dep:signal-hook-tokio", "dep:signal-hook", "dep:tokio", "dep:router_env", "dep:futures"]async_ext = ["dep:async-trait", "dep:futures"]logs = ["dep:router_env"]diff --git a/crates/common_utils/src/consts.rs b/crates/common_utils/src/consts.rsindex a5df3c4ac9..f803a2ed65 100644--- a/crates/common_utils/src/consts.rs+++ b/crates/common_utils/src/consts.rs@@ -1,5 +1,8 @@//! Commonly used constants+/// Structured log tag for external service latency events.+pub const EXTERNAL_CALL_TAG: &str = "ExternalCall";+/// Number of characters in a generated IDpub const ID_LENGTH: usize = 20;diff --git a/crates/common_utils/src/keymanager.rs b/crates/common_utils/src/keymanager.rsindex f78be112b5..9604cb6795 100644--- a/crates/common_utils/src/keymanager.rs+++ b/crates/common_utils/src/keymanager.rs@@ -11,6 +11,8 @@ use once_cell::sync::OnceCell;use router_env::{instrument, logger, tracing};use time::OffsetDateTime;+#[cfg(feature = "ext_services_latency")]+use crate::consts::EXTERNAL_CALL_TAG;use crate::{consts::{BASE64_ENGINE, TENANT_HEADER},errors,@@ -25,7 +27,7 @@ use crate::{const CONTENT_TYPE: &str = "Content-Type";static ENCRYPTION_API_CLIENT: OnceCell<reqwest::Client> = OnceCell::new();static DEFAULT_ENCRYPTION_VERSION: &str = "v1";-#[cfg(feature = "km_forward_x_request_id")]+#[cfg(any(feature = "km_forward_x_request_id", feature = "ext_services_latency"))]const X_REQUEST_ID: &str = "X-Request-Id";/// Get keymanager client constructed from the url and state@@ -96,8 +98,25 @@ where"Unable to send request to encryption service".to_string(),))?;- let latency_ms = start_time.elapsed().as_millis();+ let elapsed = start_time.elapsed();+ let latency_ms = elapsed.as_millis();let created_at_timestamp = OffsetDateTime::now_utc().unix_timestamp_nanos();+ #[cfg(feature = "ext_services_latency")]+ {+ let downstream_request_id = response+ .headers()+ .get(X_REQUEST_ID)+ .and_then(|value| value.to_str().ok());++ logger::info!(+ tag = EXTERNAL_CALL_TAG,+ operation = endpoint,+ method = method_str,+ status_code = response.status().as_u16(),+ latency_ms = elapsed.as_secs_f64() * 1000.0,+ downstream_request_id,+ );+ }if let Some(request_id) = &state.request_id {state@@ -105,7 +124,7 @@ where.emit_external_service_call(ExternalServiceCall {service_name: "keymanager".to_string(),endpoint: endpoint.to_string(),- method: method_str,+ method: method_str.clone(),request_id: request_id.clone(),status_code: response.status().as_u16(),success: response.status().is_success(),diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex 4ff59b63c1..e4f3b69a57 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -105,6 +105,54 @@ pub struct Customer {pub last_modified_by: Option<CreatedBy>,}+/// A customer view containing only fields that do not require key-manager decryption.+#[cfg(feature = "v2")]+#[derive(Clone, Debug)]+pub struct CustomerWithoutEncrypted {+ pub merchant_id: id_type::MerchantId,+ pub phone_country_code: Option<String>,+ pub description: Option<Description>,+ pub created_at: PrimitiveDateTime,+ pub metadata: Option<pii::SecretSerdeValue>,+ pub connector_customer: Option<common_types::customers::ConnectorCustomerMap>,+ pub modified_at: PrimitiveDateTime,+ pub default_payment_method_id: Option<id_type::GlobalPaymentMethodId>,+ pub updated_by: Option<String>,+ pub merchant_reference_id: Option<id_type::CustomerId>,+ pub id: id_type::GlobalCustomerId,+ pub version: common_enums::ApiVersion,+ pub status: DeleteStatus,+ pub created_by: Option<CreatedBy>,+ pub last_modified_by: Option<CreatedBy>,+}++#[cfg(feature = "v2")]+impl From<storage_types::Customer> for CustomerWithoutEncrypted {+ fn from(customer: storage_types::Customer) -> Self {+ Self {+ merchant_id: customer.merchant_id,+ phone_country_code: customer.phone_country_code,+ description: customer.description,+ created_at: customer.created_at,+ metadata: customer.metadata,+ connector_customer: customer.connector_customer,+ modified_at: customer.modified_at,+ default_payment_method_id: customer.default_payment_method_id,+ updated_by: customer.updated_by,+ merchant_reference_id: customer.merchant_reference_id,+ id: customer.id,+ version: customer.version,+ status: customer.status,+ created_by: customer+ .created_by+ .and_then(|created_by| created_by.parse::<CreatedBy>().ok()),+ last_modified_by: customer+ .last_modified_by+ .and_then(|last_modified_by| last_modified_by.parse::<CreatedBy>().ok()),+ }+ }+}+impl Customer {#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]@@ -921,6 +969,7 @@ where) -> CustomResult<Customer, Self::Error>;#[cfg(feature = "v2")]+ // TODO: Remove merchant_id from here once `id` is an unique key in DBasync fn find_customer_by_global_id_merchant_id(&self,id: &id_type::GlobalCustomerId,@@ -928,6 +977,15 @@ wherekey_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<Customer, Self::Error>;++ #[cfg(feature = "v2")]+ // TODO: Remove merchant_id from here once `id` is an unique key in DB+ async fn find_customer_by_global_id_merchant_id_without_encrypted(+ &self,+ id: &id_type::GlobalCustomerId,+ merchant_id: &id_type::MerchantId,+ storage_scheme: MerchantStorageScheme,+ ) -> CustomResult<CustomerWithoutEncrypted, Self::Error>;}#[cfg(feature = "v1")]diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.tomlindex 9fcf6346e1..96a942774d 100644--- a/crates/hyperswitch_interfaces/Cargo.toml+++ b/crates/hyperswitch_interfaces/Cargo.toml@@ -14,6 +14,7 @@ v2 = ["api_models/v2", "common_utils/v2", "hyperswitch_domain_models/v2"]payouts = ["hyperswitch_domain_models/payouts"]frm = ["hyperswitch_domain_models/frm"]revenue_recovery = []+ext_services_latency = [][dependencies]actix-web = "4.11.0"diff --git a/crates/hyperswitch_interfaces/src/api_client.rs b/crates/hyperswitch_interfaces/src/api_client.rsindex b41e1231eb..382e170aa5 100644--- a/crates/hyperswitch_interfaces/src/api_client.rs+++ b/crates/hyperswitch_interfaces/src/api_client.rs@@ -4,6 +4,8 @@ use std::{};use common_enums::{ApiClientError, PaymentMethod, PaymentMethodType};+#[cfg(feature = "ext_services_latency")]+use common_utils::consts::EXTERNAL_CALL_TAG;use common_utils::{consts::{X_CONNECTOR_NAME, X_FLOW_NAME, X_PAYMENT_METHOD, X_PAYMENT_METHOD_TYPE, X_REQUEST_ID,@@ -497,11 +499,29 @@ pub async fn call_connector_api(let current_time = Instant::now();let headers = request.headers.clone();let url = request.url.clone();+ #[cfg(feature = "ext_services_latency")]+ let method = request.method.to_string();let response = state.get_api_client().send_request(state, request, None, true).await;+ #[cfg(feature = "ext_services_latency")]+ if let Ok(resp) = response.as_ref() {+ let downstream_request_id = resp+ .headers()+ .get(X_REQUEST_ID)+ .and_then(|value| value.to_str().ok());+ logger::info!(+ tag = EXTERNAL_CALL_TAG,+ operation = flow_name,+ method,+ status_code = resp.status().as_u16(),+ latency_ms = current_time.elapsed().as_secs_f64() * 1000.0,+ downstream_request_id,+ );+ }+match response.as_ref() {Ok(resp) => {let status_code = resp.status().as_u16();diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex 1561b41849..725adfd1e7 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -46,6 +46,11 @@ encryption_service = ["payment_methods/encryption_service",]km_forward_x_request_id = ["common_utils/km_forward_x_request_id"]+# Emits structured latency logs for downstream calls and propagates request IDs for correlation.+ext_services_latency = [+ "common_utils/ext_services_latency",+ "hyperswitch_interfaces/ext_services_latency",+]frm = ["api_models/frm","hyperswitch_domain_models/frm",diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 4f25dd2abf..2b72c88aa6 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -1556,10 +1556,9 @@ pub async fn create_persistent_payment_method_core(.get_required_value("customer_id")?;let key_manager_state = &(state).into();- db.find_customer_by_global_id_merchant_id(+ db.find_customer_by_global_id_merchant_id_without_encrypted(&customer_id,platform.get_provider().get_account().get_id(),- platform.get_provider().get_key_store(),platform.get_provider().get_account().storage_scheme,).await@@ -1666,10 +1665,9 @@ pub async fn create_volatile_payment_method_core(let key_manager_state = &(state).into();if let Some(ref customer_id) = customer_id {- db.find_customer_by_global_id_merchant_id(+ db.find_customer_by_global_id_merchant_id_without_encrypted(customer_id,platform.get_provider().get_account().get_id(),- platform.get_provider().get_key_store(),platform.get_provider().get_account().storage_scheme,).await@@ -2003,14 +2001,22 @@ impl LockerOperations for GenericLocker {) -> RouterResult<PaymentMethodResolver> {let db = &*state.store;- let fingerprint_id = vault::get_fingerprint_id_for_payment_method(- state,- &payment_method_data,- customer_id.get_string_repr().to_owned(),- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to get fingerprint_id from vault using generic strategy")?;+ let (fingerprint_id_result, auxiliary_fingerprint_id_result) = tokio::join!(+ vault::get_fingerprint_id_for_payment_method(+ state,+ &payment_method_data,+ customer_id.get_string_repr().to_owned(),+ ),+ vault::get_auxiliary_fingerprint_id_for_payment_method(+ state,+ &payment_method_data,+ customer_id.get_string_repr().to_owned(),+ ),+ );++ let fingerprint_id = fingerprint_id_result+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to get fingerprint_id from vault using generic strategy")?;match db.find_payment_method_by_fingerprint_id(@@ -2062,13 +2068,7 @@ impl LockerOperations for GenericLocker {logger::debug!("Payment method not found, falling back to creation");- let auxiliary_fingerprint_id =- vault::get_auxiliary_fingerprint_id_for_payment_method(- state,- &payment_method_data,- customer_id.get_string_repr().to_owned(),- )- .await+ let auxiliary_fingerprint_id = auxiliary_fingerprint_id_result.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to get auxiliary fingerprint_id from vault using generic strategy",@@ -3749,10 +3749,9 @@ pub async fn payment_method_intent_create(let customer_id = req.customer_id.to_owned();let key_manager_state = &(state).into();- db.find_customer_by_global_id_merchant_id(+ db.find_customer_by_global_id_merchant_id_without_encrypted(&customer_id,provider.get_account().get_id(),- provider.get_key_store(),provider.get_account().storage_scheme,).await@@ -5323,10 +5322,9 @@ pub async fn list_payment_methods_core(.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;let customer = db- .find_customer_by_global_id_merchant_id(+ .find_customer_by_global_id_merchant_id_without_encrypted(customer_id,provider.get_account().get_id(),- provider.get_key_store(),provider.get_account().storage_scheme,).await@@ -5381,10 +5379,9 @@ pub async fn list_customer_payment_methods_core(.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;let customer = db- .find_customer_by_global_id_merchant_id(+ .find_customer_by_global_id_merchant_id_without_encrypted(customer_id,provider.get_account().get_id(),- provider.get_key_store(),provider.get_account().storage_scheme,).await@@ -6193,10 +6190,9 @@ pub async fn delete_payment_method_core()?;let _customer = db- .find_customer_by_global_id_merchant_id(+ .find_customer_by_global_id_merchant_id_without_encrypted(customer_id,platform.get_provider().get_account().get_id(),- platform.get_provider().get_key_store(),platform.get_provider().get_account().storage_scheme,).awaitdiff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rsindex 76fb2000fb..82e1e24651 100644--- a/crates/router/src/core/payment_methods/vault.rs+++ b/crates/router/src/core/payment_methods/vault.rs@@ -1995,6 +1995,18 @@ pub async fn call_to_vault<V: pm_types::VaultingInterface>() -> CustomResult<String, errors::VaultError> {let locker = &state.conf.locker;let jwekey = state.conf.jwekey.get_inner();+ let additional_headers = if cfg!(feature = "ext_services_latency") {+ let mut additional_headers = additional_headers.unwrap_or_default();+ if let Some(request_id) = state.request_id.as_ref() {+ additional_headers.insert(+ common_utils::consts::X_REQUEST_ID.to_string(),+ request_id.to_string(),+ );+ }+ additional_headers+ } else {+ additional_headers.unwrap_or_default()+ };let request = create_vault_request::<V>(jwekey,@@ -2002,7 +2014,7 @@ pub async fn call_to_vault<V: pm_types::VaultingInterface>(payload,state.tenant.tenant_id.to_owned(),query_params,- additional_headers,+ Some(additional_headers),).await?;let response = services::call_connector_api(state, request, V::get_vaulting_flow_name())diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rsindex 65e5690904..0c0b3f8577 100644--- a/crates/router/src/db/kafka_store.rs+++ b/crates/router/src/db/kafka_store.rs@@ -570,6 +570,22 @@ impl CustomerInterface for KafkaStore {.await}+ #[cfg(feature = "v2")]+ async fn find_customer_by_global_id_merchant_id_without_encrypted(+ &self,+ id: &id_type::GlobalCustomerId,+ merchant_id: &id_type::MerchantId,+ storage_scheme: MerchantStorageScheme,+ ) -> CustomResult<domain::CustomerWithoutEncrypted, errors::StorageError> {+ self.diesel_store+ .find_customer_by_global_id_merchant_id_without_encrypted(+ id,+ merchant_id,+ storage_scheme,+ )+ .await+ }+async fn insert_customer(&self,customer_data: domain::Customer,diff --git a/crates/storage_impl/src/customers.rs b/crates/storage_impl/src/customers.rsindex 690a0a9b1b..d85b65d6cd 100644--- a/crates/storage_impl/src/customers.rs+++ b/crates/storage_impl/src/customers.rs@@ -19,6 +19,11 @@ use crate::{utils::{pg_connection_read, pg_connection_write},CustomResult, DatabaseStore, MockDb, RouterStore,};+#[cfg(feature = "v2")]+use crate::{+ redis::kv_store::{kv_wrapper, KvOperation},+ utils::try_redis_get_else_try_database_get,+};impl KvStorePartition for customers::Customer {}@@ -503,6 +508,64 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt}}+ #[cfg(feature = "v2")]+ #[instrument(skip_all)]+ async fn find_customer_by_global_id_merchant_id_without_encrypted(+ &self,+ id: &id_type::GlobalCustomerId,+ merchant_id: &id_type::MerchantId,+ storage_scheme: MerchantStorageScheme,+ ) -> CustomResult<domain::CustomerWithoutEncrypted, StorageError> {+ let conn = pg_connection_read(self).await?;+ let database_call = || async {+ Ok::<_, error_stack::Report<StorageError>>(+ customers::Customer::find_by_global_id(&conn, id)+ .await+ .map(domain::CustomerWithoutEncrypted::from)+ .map_err(StorageError::from)?,+ )+ };+ let storage_scheme = Box::pin(decide_storage_scheme::<T, customers::Customer>(+ self,+ storage_scheme,+ Op::Find,+ ))+ .await;+ let result = match storage_scheme {+ MerchantStorageScheme::PostgresOnly => database_call().await?,+ MerchantStorageScheme::RedisKv => {+ let field = format!("cust_{}", id.get_string_repr());+ let key = PartitionKey::GlobalId {+ id: id.get_string_repr(),+ };+ Box::pin(try_redis_get_else_try_database_get(+ async {+ let customer: customers::Customer = Box::pin(kv_wrapper(+ self,+ KvOperation::<customers::Customer>::HGet(&field),+ key,+ ))+ .await?+ .try_into_hget()?;+ Ok(domain::CustomerWithoutEncrypted::from(customer))+ },+ database_call,+ ))+ .await?+ }+ };++ if result.merchant_id != *merchant_id {+ Err(StorageError::ValueNotFound(+ "db value not found".to_string(),+ ))?+ } else if result.status == common_enums::DeleteStatus::Redacted {+ Err(StorageError::CustomerRedacted)?+ } else {+ Ok(result)+ }+ }+#[cfg(feature = "v2")]#[instrument(skip_all)]async fn update_customer_by_global_id(@@ -898,6 +961,31 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {_ => Ok(customer),}}++ #[cfg(feature = "v2")]+ #[instrument(skip_all)]+ async fn find_customer_by_global_id_merchant_id_without_encrypted(+ &self,+ id: &id_type::GlobalCustomerId,+ merchant_id: &id_type::MerchantId,+ _storage_scheme: MerchantStorageScheme,+ ) -> CustomResult<domain::CustomerWithoutEncrypted, StorageError> {+ let conn = pg_connection_read(self).await?;+ let customer = customers::Customer::find_by_global_id(&conn, id)+ .await+ .map(domain::CustomerWithoutEncrypted::from)+ .map_err(StorageError::from)?;++ if customer.merchant_id != *merchant_id {+ Err(StorageError::ValueNotFound(+ "db value not found".to_string(),+ ))?+ } else if customer.status == common_enums::DeleteStatus::Redacted {+ Err(StorageError::CustomerRedacted)?+ } else {+ Ok(customer)+ }+ }}#[async_trait::async_trait]@@ -1180,4 +1268,15 @@ impl domain::CustomerInterface for MockDb {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}++ #[cfg(feature = "v2")]+ async fn find_customer_by_global_id_merchant_id_without_encrypted(+ &self,+ _id: &id_type::GlobalCustomerId,+ _merchant_id: &id_type::MerchantId,+ _storage_scheme: MerchantStorageScheme,+ ) -> CustomResult<domain::CustomerWithoutEncrypted, StorageError> {+ // [#172]: Implement function for `MockDb`+ Err(StorageError::MockDbError)?+ }}diff --git a/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/down.sql b/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/down.sqlnew file mode 100644index 0000000000..5ca96ac5b0--- /dev/null+++ b/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/down.sql@@ -0,0 +1 @@+DROP INDEX CONCURRENTLY IF EXISTS payment_methods_locker_id_index;diff --git a/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/metadata.toml b/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/metadata.tomlnew file mode 100644index 0000000000..79e9221c1f--- /dev/null+++ b/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/metadata.toml@@ -0,0 +1 @@+run_in_transaction = falsediff --git a/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/up.sql b/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/up.sqlnew file mode 100644index 0000000000..4f70725760--- /dev/null+++ b/migrations/2026-07-31-000001_add_payment_methods_locker_id_index/up.sql@@ -0,0 +1,3 @@+CREATE INDEX CONCURRENTLY IF NOT EXISTS payment_methods_locker_id_index+ON payment_methods (locker_id)+WHERE locker_id IS NOT NULL;diff --git a/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/down.sql b/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/down.sqlnew file mode 100644index 0000000000..61c4178178--- /dev/null+++ b/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/down.sql@@ -0,0 +1 @@+DROP INDEX CONCURRENTLY IF EXISTS payment_methods_locker_fingerprint_id_index;diff --git a/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/metadata.toml b/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/metadata.tomlnew file mode 100644index 0000000000..79e9221c1f--- /dev/null+++ b/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/metadata.toml@@ -0,0 +1 @@+run_in_transaction = falsediff --git a/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/up.sql b/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/up.sqlnew file mode 100644index 0000000000..ce892cbbca--- /dev/null+++ b/v2_migrations/2026-07-30-124300_add_payment_methods_locker_fingerprint_id_index/up.sql@@ -0,0 +1,3 @@+CREATE INDEX CONCURRENTLY IF NOT EXISTS payment_methods_locker_fingerprint_id_index+ON payment_methods (locker_fingerprint_id)+WHERE locker_fingerprint_id IS NOT NULL;diff --git a/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/down.sql b/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/down.sqlnew file mode 100644index 0000000000..b3c2d9b3aa--- /dev/null+++ b/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/down.sql@@ -0,0 +1 @@+DROP INDEX CONCURRENTLY IF EXISTS customers_merchant_id_reference_id_index;diff --git a/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/metadata.toml b/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/metadata.tomlnew file mode 100644index 0000000000..79e9221c1f--- /dev/null+++ b/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/metadata.toml@@ -0,0 +1 @@+run_in_transaction = falsediff --git a/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/up.sql b/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/up.sqlnew file mode 100644index 0000000000..60f2963123--- /dev/null+++ b/v2_migrations/2026-07-30-124303_add_customers_merchant_id_reference_id_index/up.sql@@ -0,0 +1,3 @@+CREATE INDEX CONCURRENTLY IF NOT EXISTS customers_merchant_id_reference_id_index+ON customers (merchant_id, merchant_reference_id)+WHERE merchant_reference_id IS NOT NULL;