xBrowse faster with less colums

xBrowse faster with less colums

Postby Marc Venken » Thu Apr 30, 2020 6:53 pm

I wonder if Xbrowse is faster with less colums ?

I use a app with 25 cols and 300.000 records. every colom has a index tag.
I use orderscope for filtering.

Speeds slows down while using

I could reduce the amount of cols (Will Xbrowse become faster ?)
I could split the data in a 2 or 3 folder system, so less data on working browse (Will Xbrowse become faster ?)

Thanks
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse faster with less colums

Postby nageswaragunupudi » Fri May 01, 2020 6:53 am

I suggest you test the speed of the same browse with only two or three columns and see.
Please also share your experience with us.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse faster with less colums

Postby Marc Venken » Fri May 01, 2020 12:00 pm

Ok will do that.

BTW : If we use colors for indicating some conditions like

oBrw:bron:bClrStd := { || showcolors(oBrw:bron:Value) }

will this function run all records of the database or only them that are visibel in Xbrowse
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse faster with less colums

Postby nageswaragunupudi » Fri May 01, 2020 12:48 pm

This codeblock is evaluated while painting every visible cell. Evaluated only for cells visible on the screen.

Assume you have a browse with 20 columns and 300,000 rows but on the screen we see 10 columns and 40 rows.

When full refresh is called, xbrowse evaluates all relevant codeblocks for 40 x 10 = 400 cells and paints all 400 cells.

Most of the time only one row gets repainted. In such cases only 10 cells are painted.

When we scroll up and down, the screen is scrolled (every cell is not repainted) and only the new row at bottom or top is painted. So only 10 cells are painted.

If we do not have different bClrStd for different columns and use oBrw:lFastDraw is set to .T.:
oBrw:bClrStd is evaluated only once and the cells are drawn faster.

Actual performance mostly depends on the speed at whith the RDD reads the database from the remote server. This is slower when the Record Length is large and CDX file is larger.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse faster with less colums

Postby Marc Venken » Fri May 01, 2020 1:02 pm

This clears things up. Thanks.

I only use Dbf and CDX, and initial speed is pretty ok. but using the program ( setting values in Barget and scoping for the correct data ) the program slows down
until i finaly can get a cup of coffee and when I return, its ready... :D :D (I'm sure... not correct programming, thats clear) It's not a commercial product or so, but all my projects for my company are dependent on Xbrowse.
(80% time I'm using xbrowse)

So, I need to get Xbrowse best running...and this weekend, I have some extra time for Xbrowse.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse faster with less colums

Postby nageswaragunupudi » Fri May 01, 2020 1:07 pm

program slows down
until i finaly can get a cup of coffee and when I return, its ready.

This is too bad.
It can not be like this. Size of 300,000 records is nothing.
We can not comment unless we get into the exact code.

Do you have too many deleted records? In that case the performance can be very sluggish. Try packing the DBF and then run.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse faster with less colums

Postby Marc Venken » Fri May 01, 2020 1:15 pm

This is the code i'm working on and try to uptimize...

You see a lot of rems ( // ) because of tests

Most used and slowing the process down = the button Set filter calling the function Setfilter

Maybe you can have a look at bad object/code ? Would be very nice.



Code: Select all  Expand view

static function mailbulk()

   local oDlg, oFont, oBrw,cfactart := "dial", nWild := 2
   local cList, aFlds, aHdrs, oBold
   local nChoice, uDataSource, nCombo1:= 1 , nCombo2:= 1
   local aBtn:= {} ,aBtn2:= {}
   local aGroepen:={}, aBron:={}
   local lDubbel    := .f., Ldeleted := .t.
   local lUseFilter  := .f.


   PUBLIC aMailgroepen:= {}

   use acties NEW

   USE GROEPEN new
   aMail:= groepen->(FW_DbfToArray())
   aMailgroepen:= ArrTranspose( aMail )[ 2 ]
   close groepen

   ASize( aBtn, len(aMailgroepen))
   ASize( aBtn2, len(aMailgroepen))

   use mailbulk NEW VIA "DBFCDX"
   mailbulk->(dbsetorder("email"))
   //SET FILTER TO !DELETED()  I pack all delete from now on !!
   mailbulk->(dbgotop())
   DBEVAL( { || If( AScan( aGroepen, FIELD->groep ) == 0, AAdd( aGroepen, FIELD->groep ), nil ) } )
   ASORT( aGroepen )
   mailbulk->(dbgotop())
   DBEVAL( { || If( AScan( aBron, FIELD->nacebel ) == 0, AAdd( aBron, FIELD->nacebel ), nil ) } )
   ASORT( aBron )

   countselection()

   //DBSELECTAREA( "mailbulk" )

   DEFINE FONT oBold NAME 'CALIBRI' SIZE 0,-12 BOLD
   DEFINE FONT oFont NAME "CALIBRI" SIZE 0,-12


   DEFINE DIALOG oDlg SIZE 1600,800 PIXEL TRUEPIXEL ;
   TITLE "Mailings : ";
   GRADIENT { { 1, nRGB( 125, 155, 175 ), nRGB( 125, 155, 175 ) } }


   DEFINE BUTTONBAR oBar OF oDlg SIZE 56,56 2007



/////////////////////////////////////////////////////////////////  BRW /////////////////////////////////////////////////
/*
   { "klantcode"  , "Klant"         ,nil,  45 }, ; // 1
   { "Adres"      , "Straat"        ,nil,  75 }, ; // 1
   { "Postcode"   , "Post"          ,nil,  35 }, ; // 1
   { "Gemeente"   , "Gemeente"      ,nil,  75 }, ; // 1
   { "Personen"   , "Pers"          ,nil,  40 }, ; // 3
   { "Totomzet"   , "Omzet"         ,nil,  50 }, ; // 3
   { "Dat_lst"    , "Dat_Lst"       ,nil,  50 }, ; // 3

*/


   aVelden :=  { ;
   { "email"      , "Email"         ,nil, 150 }, ; // 7
   { "naam"       , "Naam"          ,nil, 100 }, ; // 1
   { "optout"     , "Optout"        ,nil,  50 }, ; // 1
   { "nomails"    , "Nooit"         ,nil,  50 }, ; // 1
   { "klanttype"  , "Type"          ,nil,  35 }, ; // 1
   { "Nacebel"    , "Activiteit"    ,nil, 150 }, ; // 1
   { "Groep"      , "Groep"         ,nil, 150 }, ; // 4
   { "Bron"       , "Bron"          ,nil, 150 }, ; // 3
   { "selectie"   , "Sel"           ,nil,  35 }, ; // 5
   { "dubbel"     , "Dub"           ,nil,  35 }, ; // 5
   { "mail001"    , "M1"            ,nil,  40 }, ; // 6
   { "mail002"    , "M2"            ,nil,  40 }, ; // 6
   { "mail003"    , "M3"            ,nil,  40 }, ; // 6
   { "mail004"    , "M4"            ,nil,  40 }, ; // 6
   { "mail005"    , "M5"            ,nil,  40 }, ; // 6
   { "mail006"    , "M6"            ,nil,  40 }, ; // 6
   { "mail007"    , "M7"            ,nil,  40 }, ; // 6
   { "mail008"    , "M8"            ,nil,  40 }, ; // 6
   { "mail009"    , "M9"            ,nil,  40 }}   // 19

   @ 70,10 XBROWSE oBrw size 1400,500 PIXEL OF oDlg font oFont ;
      DATASOURCE "mailbulk";
      COLUMNS aVelden;
      AUTOSORT CELL LINES NOBORDER FOOTERS
      //FASTEDIT

//     oBrw:bRClicked := { || changeindex_klant ( oBrw ),oBrw:refresh()  }
      //oBrw:nEditTypes = EDIT_GET

//     oBrw:aCols[1]:bRClickHeader := {|| oBrw:Seek( "" ), DBSETORDER("klantnum"),oBrw:refresh()}

     oBrw:nEditTypes = EDIT_GET
     oBrw:lF2KeyToEdit := .t.  // Edit when F2 is pressed
     oBrw:bRClickHeaders := { || XbrColSelector( oBrw ) }
//     oBrw:bRClicked := { || XbrShowSizes( oBrw )  }

     oBrw:SetChecks()
     //oBrw:bKeychar := {|nkey| iif(nkey=VK_ADD,MsgInfo("Mi Funcion"),)}

     //oBrw:bKeyDown = { | nKey |(IIF(nKey = VK_INSERT, MsgInfo("Insert") ,IIF(nKey = VK_ADD  , MsgInfo("ADD") , ) , ) oBrw:Refresh()) }
     oBrw:bKeyDown := {|nkey| iif(nkey=VK_ADD,  iif(oBrw:sel:VALUE=.t.,oBrw:sel:VarPut( .F. ),oBrw:sel:VarPut( .t. ))  ,)}

     oBrw:bron:bClrStd := { || showcolors(oBrw:bron:Value)  }

     //oBrw:nRowSel := 1 and oBrw:Refresh() should bring the current row to top.
     //oBrw:M1:bLClickHeader := { |r,c,f,oCol| countacties(M1),oBrw:refresh() }

   // Relevant Code
   /*
   oBrw:M9:nFooterType := AGGR_COUNT
   oBrw:M9:bSumCondition := { || mailbulk->mail009 }
   oBrw:MakeTotals()
   */

 for n := 1 to Len( oBrw:aCols )
      WITH OBJECT oBrw:aCols[ n ]
         if :cDataType != 'L'
            :uBarGetVal    := uValBlank( :Value )
            :cBarGetPic    := :cEditPicture
         endif
      END
   next
/*
   for n := 1 to Len( oBrw:aCols )
      WITH OBJECT oBrw:aCols[ n ]
         if FieldType( n ) != 'L'
            :uBarGetVal    := uValBlank( fieldGet( n ) )
            if FieldType( n ) == 'N'
               :cBarGetPic := NumPict( FieldLen( n ), FieldDec( n ) )
            endif
         endif
      END
   next
   oBrw:lGetBar   := .F.
   //oBrw:lSeekWild := .t.
      */

   //


/*
   WITH OBJECT oBrw:InsCol( 1 )
      :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
      :SetCheck()
      :nHeadBmpNo    := 2

   END
 */


   WITH OBJECT oBrw

   /*
      WITH OBJECT oBrw
        :Sel:SetCheck( nil, nil, { 'Si', 'No' } )
      END
    */

//      :M7:bLClickHeader := { |r,c,f,oCol| ShowCount( oCol ) }
//      :M6:bLClickHeader := { |r,c,f,oCol| ShowCount( oCol ) }



      WITH OBJECT:Groep
       :nEditType     := EDIT_LISTBOX
       :aEditListTxt  := aGroepen
       :uBarGetVal    := uValBlank( :Value )
       :aBarGetList:= aGroepen
      END
      WITH OBJECT:activiteit
       :nEditType     := EDIT_LISTBOX
       :aEditListTxt  := aBron
       :uBarGetVal    := uValBlank( :Value )
       :aBarGetList:= aBron
      END


      :SetGroupHeader( "Mailings", oBrw:oCol("M1"):nCreationOrder, oBrw:oCol("M9"):nCreationOrder )
      :bRClicked        := {|nRow, nCol| MenuPop( nRow,nCol, oBrw ),oBrw:refresh() }
*/
//      :nFreeze:=11

      :nFreeze:=4
      :lSeekbar   := .T.

      :lFooter          := .t.
      :email:bFooter    := { | oCol | Len( oBrw:aSelected ) }

      :bRecSelHeader    := { || "RowNo" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont  // optional
      :nRecSelWidth     := "999999" // required size

      //:bKeyChar      := { |nKey| If( nKey == VK_ADD, ( msginfo(nKey), oBrw:selectie:VarPut( .t. )) , nil ) }
//      :bKeyChar      := { |nKey| If( nKey == VK_RETURN,;
//                       ( oBrw:sel:VarPut( .t. ) , oBrw:refresh() ), nil ) }

      //   :bOnChange     := { |oCol,uOldVal| oBrw:kleur:VarPut( tempfoto->foto ) }

      //:nStretchCol   := 10

      //:lDisplayZeros    := .f.
      //:nStretchCol      := 4

      /*
      :lIncrFilter   := .t.
      :lSeekWild     := ( nWild == 2 )
      :cFilterFld    := "Klant_nr"
      */


      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW }}
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }


      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS

      // Searchbalk

      //:lIncrFilter   := .t.
      //:lSeekWild     := ( nWild == 2 )
      //:cFilterFld    := "naam"
      //:bFooters         := { |oCol| If( Empty( oCol:cOrder ), "", oBrw:cSeek("") ) }
      //:oSeek            := TSeek():New( oBrw )

      //:bChange := { || SET_SCOPE_mailings(aMails),oStru:Refresh(),oBrw:setfocus(),odlg:update() }

   END


   BrwBarBtns( oBar, oBrw )

   oBrw:CreateFromCode()


/////////////////////////////////////////////////////////////////  BRW2 /////////////////////////////////////////////////

   aVelden2 :=  { ;
   { "Code"       , "Code"          ,nil,  60 }, ; // 7
   { "Lijst"      , "Lijst"         ,nil,  35 }, ; // 1
   { "Datum"      , "Datum"         ,nil, 110 }, ; // 1
   { "Benaming"   , "Omschrijving"  ,nil, 150 }, ; // 1
   { "Verzonden"  , "Send"          ,nil,  60 }, ; // 1
   { "Opens"      , "Open"          ,nil,  60 }, ; // 1
   { "Bounced"   ,  "Bounce"        ,nil,  60 }, ; // 1
   { "Optout"     , "OptOut"        ,nil,  60 }, ; // 1
   { "Noopen"     , "No_Open"       ,nil,  60 }, ;   // 19
   { "Titel"      , "Mailing Titel" ,nil, 350 }}   // 19

   @ 590,10 XBROWSE oBrw2 size 1400,150 PIXEL OF oDlg font oFont ;
      DATASOURCE "acties";
      COLUMNS aVelden2;
      AUTOSORT CELL LINES NOBORDER FOOTERS
      //FASTEDIT

     oBrw2:nEditTypes = EDIT_GET
     oBrw2:lF2KeyToEdit := .t.  // Edit when F2 is pressed
     oBrw2:bRClickHeaders := { || XbrColSelector( oBrw ) }
     oBrw2:bRClicked := { || XbrShowSizes( oBrw )  }
     //oBrw:M1:bLClickHeader := { |r,c,f,oCol| countacties(M1),oBrw:refresh() }


   WITH OBJECT oBrw2

*/
      :lFooter          := .t.
      :bRecSelHeader    := { || "RowNo" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont  // optional
      :nRecSelWidth     := "999999" // required size

      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW }}
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }

      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS

   END

   oBrw2:CreateFromCode()

///////////////////////////////////////////////// KNOPPEN VOOR PLOEGEN FILTER /////////////////////////////////////////////////////////////////

/*
   @ 60, 1450 CHECKBOX lDubbel PROMPT "Dubbels" SIZE 60,20 PIXEL OF oDlg ;
      ON CHANGE ( oDlg:AEvalWhen(), ;
            oBrw:cAlias )->( SetFilterLogical( oBrw, lDubbel, lUseFilter ) )
 */


   @ 60, 1550 CHECKBOX lDeleted PROMPT "Deleted" SIZE 60,20 PIXEL OF oDlg ;
      ON CHANGE ( oDlg:AEvalWhen(), ;
            oBrw:cAlias )->( SetFilterDeleted( oBrw, lDeleted ) )


   nMove:=0
   nTop:= 80
   nLeft:= 1450


   for ib = 1 to len(aMailgroepen)
      nMove+=30
      if ib = 16
           nMove:=30
           nTop:= 80
           nLeft:= 1350
      endif
      @ nTop+nMove,nLeft BTNBMP aBtn[ib] OF oDlg SIZE 150, 25 NOBORDER PROMPT alltrim(aMailgroepen[ib]) 2007 ACTION (SET_SCOPE_mailbulk(::cCaption), oBrw:GoTop(),oBrw:setfocus(), oBrw:Refresh() ) font oBold CENTER
   next
   nMove+=30
   @ nTop+nMove,nLeft BTNBMP aBtnall OF oDlg SIZE 150, 25 NOBORDER PROMPT "Alle Mails" 2007 ACTION (("mailbulk")->( ORDSCOPE(0, "" )) ,("mailbulk")->( ORDSCOPE(1, "" ) ), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
   nMove+=30
   @ nTop+nMove,nLeft BTNBMP aBtnGemeente OF oDlg SIZE 150, 25 NOBORDER PROMPT "Deze gemeente" 2007 ACTION (SET_SCOPE_gemeente(), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
   nMove+=30
   @ nTop+nMove,nLeft BTNBMP aBtnimport OF oDlg SIZE 150, 25 NOBORDER PROMPT "Read YMLP" 2007 ACTION (readymlp(), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
   nMove+=30
   @ nTop+nMove,nLeft BTNBMP aBtnexport OF oDlg SIZE 150, 25 NOBORDER PROMPT "Export YMLP" 2007 ACTION (exportymlp(), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER

   @  590,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER ;
      PROMPT { || If( oBrw:lGetBar, "Hide GetBar", "ShowGetBar" ) } 2007 ;
      ACTION ( oBrw:lGetBar := ! oBrw:lGetBar, oBrw:Refresh() ) FONT oBold CENTER
   @  630,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER PROMPT "Set Filter" 2007 ;
      ACTION ( oBrw:cAlias )->( SetFilter( oBrw ) ) FONT oBold CENTER
   @  670,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER PROMPT "Clear Filter" 2007 ACTION ( oBrw:cAlias )->( DBCLEARFILTER(),oBrw:Refresh(), oBrw:SetFocus() ) FONT oBold CENTER
   @  710,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER PROMPT "Wis Selectie" 2007 ;
      ACTION ( Clearselection(),oBrw:refresh(),oBtntot:refresh() ) FONT oBold CENTER
   @  750,1450 BTNBMP oBtntot OF oDlg SIZE 100, 35 NOBORDER PROMPT  { || c_totselected } 2007 ;
      ACTION ( countselection(),oBrw:refresh(),oBtntot:refresh() ) FONT oBold CENTER UPDATE

   @  750,1100 BTNBMP oBtnSend OF oDlg SIZE 100, 35 NOBORDER PROMPT  { || c_totsend } 2007 ;
      ACTION ( countselection(),oBrw:refresh(),oBtntot:refresh() ) FONT oBold CENTER UPDATE

   /*
   @ 150,1250 BTNBMP oBtn OF oDlg SIZE 120, 25 NOBORDER PROMPT " Clear en Zoek" 2007 ACTION (oBrw:seek(""),('klant')->(DBGOTOP()),oBrw:SetFocus())
   @ 180,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Email Rappel 1" 2007 ACTION ( druk_rappel(1),sendmail(1), oBrw:SetFocus() )
   @ 210,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Email Rappel 2" 2007 ACTION ( druk_rappel(2),sendmail(2), oBrw:SetFocus() )
   @ 240,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Facturen" 2007 ACTION xbrowse("factboek")
   @ 270,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Copy Mail" 2007 ACTION (changeemail(),oBrw:refresh() )
   */


///////////////////////////////////////////////// KNOPPEN VOOR PLOEGEN TOEWIJZEN /////////////////////////////////////////////////////////////////

   nMove:=0
   nTop:= 755
   nLeft:= -100
   nBtnsize = 100
   for i = 1 to len(aMailgroepen)
        nMove+=105
        @ nTop,nLeft+nMove BTNBMP aBtn2[i] OF oDlg SIZE nBtnsize, 25 NOBORDER PROMPT aMailgroepen[i] 2007 ACTION (setgroep(oBrw,::cCaption),oBrw:GoTop(),oBrw:refresh(),oBrw:setfocus()) font oBold CENTER
        aBtn2[i]:bClrGrad := { | lMouseOver | If( ! lMouseOver,{ { 0.1, 16764573, 16764573 },{ 0.1, 16764573, 16764573 } },{ { 0.1, 11524015, 11524015 },{ 0.1, 11524015, 11524015 } } ) }
   next

   ACTIVATE DIALOG oDlg CENTERED

    //on init ( SET_SCOPE_mailings(aMails),oBrw:gotop(),oBrw:setfocus(),oStru:refresh(),odlg:update() )

   RELEASE FONT oFont
   close all

return nil


function showcolors(cVeld)
  local cKleur:=""
  local aColorPairs := { ;
  { CLR_BLACK, MY_LIGHTGREEN },;  //1
  { CLR_BLACK, MY_GREEN},;        //2
  { CLR_BLACK, MY_PAARS},;        //3
  { CLR_BLACK, MY_LIGHTYELLOW },; //4
  { CLR_BLACK, MY_YELLOW }}       //5

  do case
    case cVeld = "MAVECO"
       cKleur = aColorPairs[2]
    case cVeld = "YMLP"
       cKleur = aColorPairs[3]
    case left(cVeld,6) = "ONLINE"
       cKleur = aColorPairs[5]
    otherwise
       cKleur = aColorPairs[1]
  endcase
return cKleur


static function SetFilter( oBrw )

   local cFilter := ""
   local n, oCol, uVal, cType
   cursorwait()
   for n := 1 to Len( oBrw:aCols )
      oCol  := oBrw:aCols[ n ]
      if ! Empty( uVal := oCol:uBarGetVal )
         if !Empty( cFilter )
            cFilter  += " .AND. "
         endif
         cType    := ValType( uVal )

         do case
         case cType == 'C'
            uVal     := Upper( AllTrim( uVal ) )
//            cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( n ) + " )"
            cFilter += '"' + uVal + '" $ UPPER( ' + oCol:CExpr + " )"
         otherwise
//            cFilter  += FieldName( n ) + " == " + cValToChar( uVal )
            cFilter  += oCol:cExpr + " == " + cValToChar( uVal )
         endcase
      endif

   next
   *******************************
   */
   //msginfo(cFilter)

   if Empty( cFilter )
      if ! Empty( DBFILTER() )
         DBCLEARFILTER()
         oBrw:Refresh()
      endif
   else
      if !( DBFILTER() == cFilter )
         SET FILTER TO &cFilter
         GO TOP
         oBrw:Refresh()
      endif
   endif

   oBrw:SetFocus()

return nil


The indexes are like this :

function mailreorganisatie()
  field email,groep,naam,gemeente,klanttype,mail001,nacebel,postcode,mail002,mail003,mail004,mail005,bron,selectie,totomzet
  field mail006,mail007,mail008,mail009,dubbel
  cursorwait()
  erase mailbulk.cdx
  use mailbulk NEW VIA "DBFCDX" EXCLUSIVE
  select mailbulk
  PACK

  index on upper(email) tag email
  INDEX on upper(groep)+upper(naam) tag groep
  INDEX on upper(naam) tag naam
  INDEX on upper(gemeente)+upper(groep) tag Nacebel
  INDEX on upper(gemeente)+upper(nacebel) tag gemeente
  INDEX on upper(klanttype)+upper(email) tag type
  INDEX on upper(mail001) tag Mail001
  INDEX on upper(mail002) tag Mail002
  INDEX on upper(mail003) tag Mail003
  INDEX on upper(mail004)+upper(bron) tag Mail004
  INDEX on upper(mail005)+upper(bron) tag Mail005
  INDEX on upper(mail006)+upper(bron) tag Mail006
  INDEX on upper(mail007)+upper(bron) tag Mail007
  INDEX on upper(mail008)+upper(bron) tag Mail008
  INDEX on upper(mail009)+upper(bron) tag Mail009
  INDEX on upper(bron) tag bron
  INDEX on str(totomzet) tag omzet
  INDEX on selectie tag selectie
  INDEX on upper(nacebel)+upper(postcode) tag nacebel
  INDEX ON dubbel TAG dubbel
  INDEX ON DELETED() TAG DELETED
  close mailbulk
  msginfo("Reindexering gedaan")
return NIL




 
Last edited by Marc Venken on Fri May 01, 2020 1:42 pm, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse faster with less colums

Postby Marc Venken » Fri May 01, 2020 1:20 pm

nageswaragunupudi wrote:
program slows down
until i finaly can get a cup of coffee and when I return, its ready.

This is too bad.
It can not be like this. Size of 300,000 records is nothing.
We can not comment unless we get into the exact code.

Do you have too many deleted records? In that case the performance can be very sluggish. Try packing the DBF and then run.


Indeed, I had many deleted records (30.000) and was calling : SET FILTER TO !DELETED() . I put a // now and I pack all delete from now on !!
I can delete (pack) this data now and then, there is no need for handeling deleted records in this app.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse faster with less colums

Postby Marc Venken » Fri May 01, 2020 1:30 pm

Just to see :

I mostly use the buttons :

Hide getbar
setfilter
Clear filter

[img]
http://maveco.be/fivewin/fwtest.jpg
[/img]
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: xBrowse faster with less colums

Postby nageswaragunupudi » Sat May 02, 2020 2:22 am

SET FILTER TO !DELETED()
is optimized if you have an index tag on the expression DELETED()
We recommend
Code: Select all  Expand view

INDEX ON DELETED() TAG DELETED
 


Filters are optimized if your index expressions are simple
Eg:
Code: Select all  Expand view

INDEX ON UPPER(CITY) TAG CITY
 

but not
Code: Select all  Expand view

INDEX ON UPPER(CUSTOMER->CITY) TAG CITY
 


Best way to create proper indexes on all fields, including DELETED() is to use FW_CdxCreate() function:
Example:
Code: Select all  Expand view

FERASE( "CUSTOMER.CDX" )
USE CUSTOMER EXCLUSIVE
FW_CdxCreate()
CLOSE CUSTOMER
 


In your filter expression, references to the fields should match the exact expression used in the indexes.
For example,
Because we created index on UPPER(CITY),
Code: Select all  Expand view

SET FILTER TO UPPER(CITY) = "A" // optimized
SET FILTER TO CITY = "A" // not optimized
 


In addition, if you have large memo fields, speed of access by RDD will be slower.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests