Grid performance terribly slow on a file share, browse works well

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by apais »

With MEMIO you can create an in-memory dbf and/or index file
Angel Pais
Web Apps consultant/architect/developer.
HW_apache (webserver modules) co-developer.
HbTron (Html GUI for harbour desktop hybrid apps) co-developer.
https://www.hbtron.com
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid performance terribly slow on a file share, browse works well

Post by franco »

SERGE, and APAIS,
Thanks for help. I revised the program above and it works perfectly. This is a good answer for this dilemma.
Create a local index as Serge suggested. Now I could not make a memio index. Do you know how.
I tried
REQUEST HB_MEMIO
USE INV
Do not know how to create index in memory, then release when leaving browse.
Thanks again.. Franco
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by serge_girard »

Franco,

This, I wouldn't know. Never used MEMIO and I found only one demo.prg in the samples folder...
Just try and find out!

Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by serge_girard »

Franco,

Maybe this:

Code: Select all

INDEX ON NUM1 TO mem:NUM1
Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by mol »

Did you think about problems when table will be modified by another user? Local index will stay the same and disaster will be very close.
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by serge_girard »

Right, but index will be rebuild after closing browse-form. When a record is added in one form, the other browse-form will not be updated.
All depends on how crucial information is. Personally I would opt for MySQL but then also a grid will never be updated automatically.
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by serge_girard »

Franco,

Better to always open/close DBF like this sample:

Code: Select all

#include <hmg.ch>
REQUEST HB_MEMIO




FUNCTION MAIN
/****************/

if !file('p:\franco\inv.dbf')
	CF := {}
	aADD(CF,{'NUM1'       ,'C' , 15,0})
	aADD(CF,{'NUM2'       ,'C' , 15,0})

	DBCREATE( 'p:\franco\INV.DBF',CF )
	USE
   
   USE p:\franco\INV EXCLUSIVE NEW 
	DO WHILE RECNO()< 100000
      INV->( DBAPPEND())
      INV->( FIELDPUT(1, 'P' + ALLTRIM(STR(20 + RECNO())) ))
      INV->( FIELDPUT(2, 'PARTS' ))

      LOOP
	ENDDO
	USE
ENDIF


DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 1000 ;
   HEIGHT 610 ;
   TITLE 'Browse Test' ;
   MAIN 
   
   @ 10,10 BUTTON Button_1 CAPTION 'Browse' WIDTH 75 HEIGHT 75 MULTILINE ;
            NOTABSTOP TOOLTIP 'Browse Inv' ;
          ACTION { || BRWCRS(87, 228, 220, 100, 390, 'ITEM', 'OH ', "INV", 'NUM1', 'NUM2') }

   @ 100,10 BUTTON Button_2 CAPTION 'Insert' WIDTH 75 HEIGHT 75 MULTILINE ;
            NOTABSTOP TOOLTIP 'Insert Inv' ;
          ACTION Append_Record() 
   
      END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

Return






function brwcrs
LOCAL WID1, OSEL
PARAMETERS R1, C1, W1, W2, H1, H2, H3, T1, FC1, FC2      // TA, W1, W2, C1, R1, H1, I1, D1, FC1, FC2
// R1 = ROW.... C1 = COLUMN.... W1 = WIDTH OD FIRST FIELD.... W2 = WIDTH OF SECONFD FIELD
// H1 = HEIGHT.... H2 = HEADER 1.... H3 = HEADER 2.... T1 = TABLE.... FC1 = FIELD1.... FC2 = FIELD 2

If IsWIndowActive (frmQSMain) 
   DoMethod ('frmQSMain' ,  'Release' )   
ENDIF

OPNFLS()


IF W2 = 0
   WID1 := 'FC1'
ELSE 
   WID1 := 'FC1 , FC2'
ENDIF  




DEFINE WINDOW frmQSMain ;
   AT  R1+80, C1+10 ;
   WIDTH W1+W2+40 ;      //GetDesktopWidth() * 0.75 ;
   HEIGHT H1+20 ;  // GetDesktopHeight() * 0.75 ;
   WINDOWTYPE CHILD ;
   TITLEBAR .F.  ;
   ON RELEASE CLSFLS();   

   ON KEY ESCAPE ACTION { || MKEY := .T., frmQSMain.Release}


   DEFINE BROWSE brwItems
      ROW         0     //133
      COL         0     //211
      WIDTH       W1 + W2+25  // 400
      HEIGHT      H1  //290
      BACKCOLOR   { 255, 255, 255}
      FONTCOLOR   { 0, 0, 0 }
      HEADERS     {H2 , H3}
      WIDTHS      {W1, W2}
      WORKAREA    &T1 //inv
      FIELDS      { &WID1}
      ONDBLCLICK  { || EDITINV(this.value), frmQSMain.Release  }
     // ONLOSTFOCUS { || dbgoto(this.value), frmQSMain.Release } 
     // ONCHANGE    { || dbgoto(this.value) }
      TOOLTIP     'Press Escape to Exit'
      NOLINES     .F.
   END BROWSE     // brwItems

   DEFINE TEXTBOX textSearch
      ROW 1 //R1
      COL 1  //232
      WIDTH 1 // 200 can make 1 so you cannot see
      HEIGHT 24
      ONCHANGE { || DBSEEK( UPPER( this.Value ), .T. ), frmQSMain.brwItems.value := &T1->(RECNO() ) }
      ONENTER { || frmQSMain.brwItems.SETFOCUS }
      ONLOSTFOCUS { || frmQSMain.brwItems.SETFOCUS}
   END TEXTBOX // tbxSearch

END WINDOW // frmQSMain  

frmQSMain.textSEARCH.SETFOCUS
frmQSMain.Activate
return






FUNCTION OPNFLS()
/**************/
LOCAL CF

SELECT 1
USE p:\franco\INV SHARED
INDEX ON NUM1 TO mem:NUM1
RETURN




FUNCTION CLSFLS()
/*************/
CLOSE ALL
RETURN



FUNCTION Append_Record() 
/***********************/
OPNFLS()
INV->( DBAPPEND())
INV->( FIELDPUT(1, 'a' + ALLTRIM(STR(20 + RECNO())) ))
INV->( FIELDPUT(2, 'PARTa' ))
CLSFLS()




FUNCTION EDITINV(tvalue)
/***************************/
OPNFLS()
GOTO(tvalue)
MSGINFO ( NUM1 + ' ' + NUM2)
CLSFLS()
Serge
There's nothing you can do that can't be done...
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid performance terribly slow on a file share, browse works well

Post by franco »

I dreamed last night what Mol mentioned. And now have it fixed. I do not add records in my browse function.
In my server computer I have a unique folder SEND, so if this folder does not exist in a terminal and reccount() > 1000 which
seems to be the slowing point, then I create temp index to a folder created in all terminal computers.
I have 4 indexes in the the inv file originally.
My browse is in a different program, and is only for getting a item to set a table . The new system works as follows:
private mrec, nord := indexord()
do the browse
mrec := recno()
set order to nord
go mrec

Seems to work good.
Serge, I think it best to stay out of memory as we do not want to use to much memory. I do NOT have to erase temp index as
it is only being use by its own terminal and just over writes as its created.
When I make double sure everything is working perfect I will update sample for others to see and experiment with.

Thanks again .. Franco ;)
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid performance terribly slow on a file share, browse works well

Post by serge_girard »

ok
There's nothing you can do that can't be done...
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Grid performance terribly slow on a file share, browse works well

Post by franco »

I am trying to check to see if there is a folder for the demo above. Can not figure out as I can keep creating a folder
and it works but if the folder exists I should not create need to create it.
Like this: if ! folder("c:\temp") \\ this does not work
createfolder("c:\temp") \\this works
endif
I know there must be a way ... Franco
All The Best,
Franco
Canada
Post Reply