From a15c051098dd7ded735b9d15df683c269d9ee36c Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Sep 2022 08:07:46 +0200 Subject: [PATCH] fix(monitor_salesFilter): mariadb not optimize query --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 0b97b11e1..ff642b088 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -164,6 +164,10 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); + + stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`); + stmts.push(`SET SESSION optimizer_search_depth = 0`); + stmt = new ParameterizedSQL( `CREATE TEMPORARY TABLE tmp.filter (PRIMARY KEY (id)) @@ -224,6 +228,8 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmts.push(stmt); + stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`); + // Get client debt balance stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt'); stmts.push(` -- 2.40.1