Very slow SQL query in Openedge database, what can it be?

Asked

Viewed 170 times

0

I’m having trouble executing queries in the Openedge 11.6 database. Several queries take a long time to be executed, sometimes almost 2 minutes.

Here’s an example of a query I’m trying to run:

SELECT
docto_item.cod_fil,
count(*) qtd_item,
sum(docto_item.vlr_item_bruto) as vl_nota,
sum(docto_item.vlr_icms) as vl_icm,
sum(docto_item.vlr_pis),
sum(docto_item.vlr_cofins),
sum(docto_item.vlr_icms_subst) as vlr_icms_subst
FROM
pub.docto_item, pub.docto
WHERE

docto_item.cod_emp=1
AND docto_item.cod_fil=5
AND docto_item.tipo_ent_sai=0 --0 = Saida ou 1 = entrada
AND docto_item.dt_movto='2017-09-22'
AND docto.modulo='edi'
AND docto.cod_destino=docto_item.cod_destino
AND docto.cod_emp=docto_item.cod_emp
AND docto.cod_fil=docto_item.cod_fil
AND docto.num_docto=docto_item.num_docto
AND docto.serie_docto=docto_item.serie_docto
GROUP BY docto_item.cod_fil;

I know just looking at the consult can make it hard to know what it might be. But if there is someone who has had this problem and managed to solve, it would be very good.

  • I’m not familiar with Openedge but check the basics , indexes etc https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/index-Function.html https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dmsrf/update-statistics.html

1 answer

0

Based on the comment I did some research and managed to find the solution and I leave answered to those who have the same problem.

I informed in the query the clause with(index(nome_do_indice)) sort of like this:

SELECT CAMPO
FROM TABELA T WITH (INDEX(UM_INDICE))
INNER JOIN OUTRA_TABELA OT
WITH (INDEX(OUTRO_INDICE))
ON OT.ID = T.ID

Reference: How to use a specific index in a SQL Server query?

  • Note , In Oracle the equivalent is HINT

Browser other questions tagged

You are not signed in. Login or sign up in order to post.