Otimizar Query
Tenho a seguinte Query:
select distinct lojas.cli_codigo, salles.on_behalf_of, salles.id,
lojas.cli_token, lojas.cli_email,
lojas.cli_token_f, lojas.cli_email_f,
coalesce(salles.mv_venda_tipo, '') as mv_venda_tipo
from mv_salles salles
inner join mv_loja_clientes lojas on(lojas.cli_codigo = salles.loja_codigo)
and((cli_token != '') or (cli_token_f != ''))
left join mv_vendas vendas on(vendas.code = salles.id)
and(vendas.datarequest > salles.data_request)
where (salles.adquirencia = 'setor_a')
and(vendas.code is null)
and(salles.resource = 'transaction')
and(salles.busca_venda is null)
order by 1
limit 500
Como poderia otimiza-la?
Ja tenho Index nos campos do where e joins, sem as linha (salles.adquirencia = 'setor_a') e and(salles.resource = 'transaction') a query leva 0,468seg, ja com elas leva 28,786seg é muita diferença, já tentei reescreve-la, mas quando adiciono essas linha ele fica lento... nem deveria ter indice nessas linhas ja que são dois ou três valores neles, mas adicionei pra ver se melhorava, melhorou 2 segundos
Subject
Views
Written By
Posted
Otimizar Query
500
August 11, 2021 04:54PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.