From 77974b71dc9cb1dee9edfafeaa92242c81ea1773 Mon Sep 17 00:00:00 2001 From: demonspork Date: Sat, 20 Feb 2021 02:57:08 -0600 Subject: [PATCH] Fix Query performance for cc_side agent For some unexplained reason, including the `"and cc_side != 'agent'` in the WHERE tanks the query performance from seconds to minutes on Postgres 9.4. It runs great on Postgresql 13. Reverting to the "blank content while writing the page content" approach for this value unless I can find the source of the problem. - Oh, also removed an unnecessary condition that prevents you from filtering by LOSE_RACE. --- app/xml_cdr/xml_cdr.php | 5 ++++- app/xml_cdr/xml_cdr_inc.php | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index fb139285fd..d4a1512645 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -823,7 +823,10 @@ } $content .= "\n"; - + //show agent originated legs only to those with the permission + if (!permission_exists('xml_cdr_cc_agent_leg') && $row['cc_side'] == "agent") { + $content = ''; + } //show the leg b only to those with the permission if ($row['leg'] == 'a') { echo $content; diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 619a7455e4..9e34896f7d 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -413,7 +413,7 @@ $sql .= "and billsec like :billsec "; $parameters['billsec'] = '%'.$billsec.'%'; } - if (strlen($hangup_cause) > 0 && $hangup_cause != 'LOSE_RACE') { + if (strlen($hangup_cause) > 0) { $sql .= "and hangup_cause like :hangup_cause "; $parameters['hangup_cause'] = '%'.$hangup_cause.'%'; } @@ -515,10 +515,6 @@ $sql .= "and (c.record_path is null or c.record_name is null) "; } } - //show agent originated legs only to those with the permission - if (!permission_exists('xml_cdr_cc_agent_leg')) { - $sql .= "and cc_side != 'agent' "; - } //end where if (strlen($order_by) > 0) { $sql .= order_by($order_by, $order);