From 7e78fde169d6e1b25c7e82a9bbcc399d87a2fa02 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 20 Nov 2014 11:42:22 -0800 Subject: [PATCH] optimize once_percust condition --- FS/FS/part_event/Condition/once_percust.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/FS/FS/part_event/Condition/once_percust.pm b/FS/FS/part_event/Condition/once_percust.pm index 67767f91b..2773ca020 100644 --- a/FS/FS/part_event/Condition/once_percust.pm +++ b/FS/FS/part_event/Condition/once_percust.pm @@ -52,13 +52,13 @@ sub condition_sql { my $pkey = $pkey{$table}; - "0 = ( SELECT COUNT(*) FROM cust_event - WHERE cust_event.eventpart = part_event.eventpart - AND cust_event.tablenum IN ( - SELECT $pkey FROM $table AS once_percust - WHERE once_percust.custnum = cust_main.custnum ) - AND status != 'failed' - ) + "NOT EXISTS ( SELECT 1 FROM cust_event + WHERE cust_event.eventpart = part_event.eventpart + AND cust_event.tablenum IN ( + SELECT $pkey FROM $table AS once_percust + WHERE once_percust.custnum = cust_main.custnum ) + AND status != 'failed' + ) "; } -- 2.11.0