Page 1 of 1

ARRAY or DATABASE with oLbx?

PostPosted: Mon May 04, 2009 9:48 am
by Otto
Hello Antonio,
I found out that a kind of „recordset” approach - oLbx with ARRAY - works much faster than using the database.
Are you aware of advantages / disadvantages of using ARRAYS.
Thanks in advance
Otto

With ARRAY (much faster)
Code: Select all  Expand view
do while .not. eof()
aadd(arr1,{ str(RECHNUNG->menge),str(RECHNUNG->vmenge), RECHNUNG->bezeichnun,str(RECHNUNG->Wert )})
skip
enddo

   @ 0, 0 LISTBOX oBrwRG ;
    FIELDS "", "" ,"","";
    HEADERS "ME", "VMe", "Bezeichnung","Preis" ;
    SIZE 240, 195 PIXEL OF oWndRG
   oBrwRG:bLine = { || { arr1[oBrwRG:nAt,1], arr1[oBrwRG:nAt,2], arr1[oBrwRG:nAt,3], arr1[oBrwRG:nAt,4] } }
   oBrwRG:SetArray( arr1 )
 
 



Database:

select RECHNUNG
go top

@ 0, 0 LISTBOX oBrwRG ;
FIELDS ALLTRIM(str(RECHNUNG->menge-RECHNUNG->vmenge)),ALLTRIM(str(RECHNUNG->vmenge)), RECHNUNG->bezeichnun,str(RECHNUNG->Wert);
HEADERS "ME", "VMe", "Bezeichnung","Preis";
ALIAS "RECHNUNG";
fieldsizes 30,30,110,30;
SIZE 240, 195 OF oWndRG
SELECT RECHNUNG->AKTIV FOR " " TO " "





Best regards,
Otto

Re: ARRAY or DATABASE with oLbx?

PostPosted: Mon May 04, 2009 10:34 am
by Antonio Linares
Otto,

An array is entirely hold in memory, it does not need any disk access, thus it is faster.

Anyhow, if you are doing your tests in the Pocket PC memory card, please keep in mind that the memory card as harddisk is slower than using a Pocket PC folder in its harddisk.

Re: ARRAY or DATABASE with oLbx?

PostPosted: Mon May 04, 2009 11:35 am
by Otto
Hello Antonio,
I made more tests and found out that it is the "select for to" what makes it slow.

Best regards,
Otto

Re: ARRAY or DATABASE with oLbx?

PostPosted: Mon May 04, 2009 12:12 pm
by Antonio Linares
Otto,

> "select for to"

Yes, as it works as a filter. You should always use conditional indexes instead

Re: ARRAY or DATABASE with oLbx?

PostPosted: Mon May 04, 2009 1:39 pm
by Otto
Hello Antonio,

conditional is the solution.
Now it is high speed.

Best regards,
Otto