Why does my aplications is so slow opening and whorking with tables with 20.000 records...
I dont no if this is Ok or is there anithing i can do to make it faster...
It depends on a lot of things. Filters can slow down a lot, even worst if you have filters on indexes. LAN can slow down (specially if you are still using 10 base T cards).
What is your setup?
Mike Gagnon
If you want to get the best response to a question, please check out FAQ184-2483 first
cod = upper(alltrim(thisform.cod.value))
fm1 = upper(alltrim(thisform.fm1.value))
fm2 = upper(alltrim(thisform.fm2.value))
mor = upper(alltrim(thisform.mor.value))
nom = UPPER(alltrim(thisform.nom.value))
mor = upper(alltrim(thisform.mor.value))
loc = upper(alltrim(thisform.loc.value))
cdp = upper(alltrim(thisform.cdp.value))
con = upper(alltrim(thisform.con.value))
tel = upper(alltrim(thisform.tel.value))
W = 1
do case
case thisform.opgordem.value=1
ordem = "codigo"
case thisform.opgordem.value=2
ordem = "enome"
case thisform.opgordem.value=3
ordem = "famn1,famn2"
endcase
do case
*** Fornecedores ***
case thisform.Tipo="F"
thisform.caption="Consulta de Fornecedores (entcon1)"
campo1 = "fcodigo"
campo2 = "UPPER(ffamn1)"
campo3 = "UPPER(ffamn2)"
comando = " fnumseq = enumseq "
select &campo1 as codigo, &campo2 as famn1, &campo3 as famn2 ;
, UPPER(ENOME) AS ENOME, UPPER(emorada1) as emorada1 ;
, upper(ecodp) as ecodp, upper(elocalid) as elocalid, upper(encontr) as encontr ;
, upper(etelef1) as etelef1, DELETED() AS EAPAGADO;
from thisform.ficheiros(1,1), thisform.ficheiros(3,1) ;
where &comando ;
into cursor &aux1
if cod != "" and errado = .F.
IF ATCC(cod, coden) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if fm1 != "" and errado = .F.
IF ATCC(fm1,famn1) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if fm2 != "" and errado = .F.
IF ATCC(fm2,famn2) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if nom != "" and errado = .F.
IF ATCC(NOM,enome) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if mor != "" and errado = .F.
IF ATCC(mor,Emorada1) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if loc != "" and errado = .F.
IF ATCC(loc,elocalid) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if cdp != "" and errado = .F.
IF ATCC(cdp,ecodp) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if CON != "" and errado = .F.
IF ATCC(CON,encontr) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if tel != "" and errado = .F.
IF ATCC(tel,etelef1) > 0
errado = .F.
else
errado = .T.
endif
ENDIF
if errado = .F.
insert into (tabarr) values (codigoent)
W = W + 1
ENDIF
ENDSCAN
set deleted on
cur1 = " select codigo, enome, emorada1, ecodp, elocalid, encontr, etelef1, famn1, famn2, EAPAGADO ;
from &aux1 into cursor &aux2 order by &ordem ;
where CODIGO IN (SELECT * FROM &TABARR) "
I Think that SQL query Statement takes long time and ATCC too. If you want to know the timings of each line execution try using SET COVERAGE TO filename command before executing the above codes and after finishing codes give SET COVERAGE TO. Now you can view the filename for time taken for execution of lines.
select &campo1 as codigo, &campo2 as famn1, &campo3 as famn2 ;
, UPPER(ENOME) AS ENOME, UPPER(emorada1) as emorada1 ;
, upper(ecodp) as ecodp, upper(elocalid) as elocalid, upper(encontr) as encontr ;
, upper(etelef1) as etelef1, DELETED() AS EAPAGADO;
from thisform.ficheiros(1,1), thisform.ficheiros(3,1) ;
where &comando ;
into cursor &aux1
As gchandrujs suggests I have a feeling that your SQL statement is most likely not optimized. Try removing your :
Where &comando
And see if that is the culprit. This link might help optimize your SQL:
What cjulio done with Where &comando is not wrong. He may in need of that.
I was merely suggesting, in order to narrow down the bottleneck, to remove the filter and see if there is a difference in speed, and if there is then maybe there is a way the "fine tune" the WHERE clause. I wasn't suggesting to remove permanently. Mike Gagnon
If you want to get the best response to a question, please check out FAQ184-2483 first
People my problem is the atcc statement the sql is good but i dont now in this case how to the atcc statement faster.... if there is any ideas.... Please Say....
in the SQL statement try using brackets () instead of macro substitution &.
eg
instead of
select &campo1 as codigo, &campo2 as famn1, &campo3 as famn2 ....
try
select (campo1) as codigo, (campo2) as famn1, (campo3) as famn2....
if the above is not working (usually it works), try building the statement by concatenating the parts
eg. "SELECT "+campo1+ " AS codigo,"+campo2+ " as famn1,".....
Microsoft has always said that as best as possible avoid using mcro substitution.
Another thing, instead of DELETE FILE &tabarr. try using the sys(3) function to assign a temp file. Fox will remove the file automatically once use close it.
You can also omitt the GO TOP. the SCAN funtion will automatically start at the top of the file
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.