Evaluating bids

Resolver lentidão query

Published on the January 20, 2023 in IT & Programming

About this project

Open

Query demorando mais de 4 minutos para quanto não tem registros

SELECT distinct mlci.id as mlci_id, tal.acao_id, mlc.dhEmi as data_compra, mlc.loja_id, mlc.fornecedor_id, prod.fabricante_id,
    mlci.produto_id, prod.departamento_id, dep.categoria_id, cat.area_id, prod.familia_id, mlci.qCom as quantidade,
    round((mlci.vProd - mlci.vDesc)/mlci.qCom, 2) as preco, round(mlci.vProd - mlci.Vdesc, 2) as subtotal, 1 as contar
from trade_acao as ta
inner join trade_acao_loja as tal on tal.Acao_id=ta.id
inner join trade_acordo_fabricante as taf on ta.Acordo_id=taf.acordo_id
inner join mov_loja_compra as mlc on mlc.Loja_id=tal.loja_id
inner join mov_loja_compra_item as mlci on mlci.Mov_loja_compra_id=mlc.id
inner join produto prod on mlci.produto_id=prod.id And prod.fabricante_id=taf.fabricante_id
inner join departamento dep on dep.Id=prod.departamento_id 
inner join categoria cat on dep.Categoria_id=cat.id
left join trade_compra_item as tci on tci.mlci_id=mlci.id AND tci.acao_id=ta.id
WHERE ta.id=36 AND mlci.qcom>0 AND mlc.dhEmi=20221014
AND ( cat.area_id = 5 OR  cat.area_id = 4)
And tci.id is null
order by mlc.dhEmi ASC, mlci.id LIMIT 100

Category IT & Programming
Subcategory Other
Project size Small
Is this a project or a position? Project
I currently have I have specifications
Required availability As needed

Delivery term: January 23, 2023

Skills needed

Other projects posted by P. B.