Merge pull request 'hotFix(monitor_salesFilter): mariadb not optimize query' (#1044) from hotFix_monitorSQL_optimizer into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1044
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Joan Sanchez 2022-09-08 06:22:02 +00:00
commit 44b63af0a7
1 changed files with 6 additions and 0 deletions

View File

@ -164,6 +164,10 @@ module.exports = Self => {
let stmt; let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); 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( stmt = new ParameterizedSQL(
`CREATE TEMPORARY TABLE tmp.filter `CREATE TEMPORARY TABLE tmp.filter
(PRIMARY KEY (id)) (PRIMARY KEY (id))
@ -224,6 +228,8 @@ module.exports = Self => {
stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeWhere(filter.where));
stmts.push(stmt); stmts.push(stmt);
stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);
// Get client debt balance // Get client debt balance
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt'); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt');
stmts.push(` stmts.push(`