Mr Rao, slow to create xbrowse(solved)...

Mr Rao, slow to create xbrowse(solved)...

Postby albeiroval » Thu Jun 15, 2017 4:38 am

Hi,

How can I improve the speed of creation of an xbrowse when loading data from a table with many records using tdolphin,
Probe using oBrw :: oMysql: lPagination = .T. And does not improve the speed to create xbrowse.

The code is as follows :
Code: Select all  Expand view  RUN

REDEFINE XBROWSE oBrw OF oDlg ID 100;
    DATASOURCE oQry;
    LINES FOOTERS AUTOSORT
   
  ADD TO oBrw DATA oQry:fecha                 TITLE "Fecha"                       SIZE 100    
  ADD TO oBrw DATA oQry:fecha_factura     TITLE "Fecha_Factura"   SIZE 100  
  ADD TO oBrw DATA oQry:rif_provedor       TITLE "Rif"                         SIZE 100  
  ADD TO oBrw DATA oQry:nombre_provedor TITLE "Provedor"                SIZE 300  
  ADD TO oBrw DATA oQry:numero_factura  TITLE "Factura"                 SIZE 120 FOOTER "Totales"  
  ADD TO oBrw DATA oQry:tipo                    TITLE "Tipo"                        SIZE 080 LEFT  
  ADD TO oBrw DATA oQry:montobase          TITLE "Base"                        SIZE 120 PICTURE "@E 999,999,999,999.99" TOTAL nTotBas RIGHT  
  ADD TO oBrw DATA oQry:montoexento      TITLE "Exento"                    SIZE 120 PICTURE "@E 999,999,999,999.99" TOTAL nTotExe RIGHT        
  ADD TO oBrw DATA oQry:montoiva            TITLE "Iva"                         SIZE 120 PICTURE "@E 999,999,999,999.99" TOTAL nTotIva RIGHT    
  ADD TO oBrw DATA oQry:montototal         TITLE "Total"                   SIZE 120 PICTURE "@E 999,999,999,999.99" TOTAL nTotTot RIGHT
  ADD TO oBrw DATA oQry:montoretenido    TITLE "Retencion"           SIZE 120 PICTURE "@E 999,999,999,999.99" TOTAL nTotRet RIGHT    
  ADD TO oBrw DATA oQry:periodo               TITLE "Periodo"                 SIZE 100  
 
Last edited by albeiroval on Thu Jun 15, 2017 6:22 pm, edited 6 times in total.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse

Postby nageswaragunupudi » Thu Jun 15, 2017 12:43 pm

Dolphin should be quite fast with pagination and smaller page size.

In this case, please remove all totals. We should never call oBrw:MakeTotals() for large tables (even for DBF). Let us see if the performance improves after completely removing totals and using Dolphin's pagination with page size of 100 or so.

Once we achieve acceptable performance, then we shall use some other method to display totals.
Regards

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

Re: Mr Rao, slow to create xbrowse

Postby albeiroval » Thu Jun 15, 2017 1:19 pm

Thank you, Mr. Rao,

Remove the maketotals(), now create xbrowse fast.

Add these lines:

oBrw: oMysql: lPagination = .T.
oBrw: oMysql: SetPages (100)

And to show totals ?
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse

Postby nageswaragunupudi » Thu Jun 15, 2017 1:35 pm

Totals:
1) Do not use Maketotals() but bring back your TOTAL clause.
Please make sure you never call MakeTotals() even during runtime.

2) Find totals separately with a query "SELECT SUM(...) AS .. , SUM( .. ) AS .."
Assign the values to oCol(n):nTotal, oCol(m):nTotal and so on.

We are spending some extra time for this query. But better than Browse calculating the totals.

3) If you use FASTEDIT and do inline edit, the totals are automatically recalculated.

Please also let us know your fwh version. Automatic recalculation of totals is greatly improved in recent versions.

First do upto this.
We discuss about next steps after you do this.
Regards

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

Re: Mr Rao, slow to create xbrowse

Postby Rick Lipkin » Thu Jun 15, 2017 1:42 pm

Albeiro

In cases where I know I am doing a full table scan with :MakeTotals ... I only allow totals to be created for less than 1000 records ..

Code: Select all  Expand view  RUN

If oRsWork:RecordCount() <= 1000
   oBrw:MakeTotals()
Endif
 


Not a very elegant solution, but in most situations my queries to not return more than 1000 rows and :maketotals works fine....

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Mr Rao, slow to create xbrowse

Postby albeiroval » Thu Jun 15, 2017 2:29 pm

Mr Rao,

I made the following changes, but only shows 1 record, it should be by the SUM clause of the query, how should I create the query to show all the records?

Code: Select all  Expand view  RUN

TEXT INTO cQuery
    SELECT  fecha,
                    periodo,
                    rif_provedor,
                    nombre_provedor,
                    tipo,
                    fecha_factura,
                    numero_factura,
                    control_factura,
                    montoretenido,
                    montoexento,
                montoiva,
                    montobase,
                    montototal,
                    alicuota,
                    my_recno,
                    CASE tipo
                            WHEN tipo = 1 THEN "Registro"
                            WHEN Tipo = 2 THEN "Ajuste"
                            ELSE " "
                        END AS nametipo,
                        SUM(montobase)          AS sumabase,
                        SUM(montototal)         AS sumatotal,
                        SUM(montoiva)           AS sumaiva,
                        SUM(montoretenido)  AS sumaretenido,
                        SUM(montoexento)        AS sumaexento
        FROM %1
    ORDER BY
  ENDTEXT
   
  cQuery := StrFormat( cQuery, TABLA_COMPRASFACTURAS )
 
  oQry = oSrv:CreateQuery( cQuery + "fecha" )
   
  DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12 BOLD

  DEFINE DIALOG oDlg TITLE "FACTURAS DE COMPRA" RESOURCE "XBROWSE" ICON aBitmap[ BMP32_ICON ] FONT oFont
         
  REDEFINE XBROWSE oBrw OF oDlg ID 100;
    DATASOURCE oQry;
    LINES FOOTERS AUTOSORT
   
  ADD TO oBrw DATA oQry:fecha                       TITLE "Fecha"                       SIZE 100    
  ADD TO oBrw DATA oQry:fecha_factura       TITLE "Fecha_Factura"   SIZE 100  
  ADD TO oBrw DATA oQry:rif_provedor        TITLE "Rif"                         SIZE 100  
  ADD TO oBrw DATA oQry:nombre_provedor TITLE "Provedor"                SIZE 300  
  ADD TO oBrw DATA oQry:numero_factura  TITLE "Factura"                 SIZE 120 FOOTER "Totales"  
  ADD TO oBrw DATA oQry:nametipo                TITLE "Tipo"                        SIZE 080 LEFT  
  ADD TO oBrw DATA oQry:montobase           TITLE "Base"                        SIZE 120 PICTURE "@E 999,999,999,999.99" RIGHT  
  ADD TO oBrw DATA oQry:montoexento       TITLE "Exento"                    SIZE 120 PICTURE "@E 999,999,999,999.99" RIGHT        
  ADD TO oBrw DATA oQry:montoiva                TITLE "Iva"                         SIZE 120 PICTURE "@E 999,999,999,999.99" RIGHT    
  ADD TO oBrw DATA oQry:montototal          TITLE "Total"                   SIZE 120 PICTURE "@E 999,999,999,999.99" RIGHT
  ADD TO oBrw DATA oQry:montoretenido   TITLE "Retencion"           SIZE 120 PICTURE "@E 999,999,999,999.99" RIGHT    
  ADD TO oBrw DATA oQry:periodo             TITLE "Periodo"                 SIZE 100  
       
  WITH OBJECT oBrw
    :MyConfig()
    :oMysql:SetPages( 100 )
    :QueryWithJoin( cQuery, TABLA_COMPRASFACTURAS, oQry )
   
    :aCols[1]:cSortOrder = "fecha"    
    :aCols[2]:cSortOrder = "fecha_factura"    
    :aCols[3]:cSortOrder = "rif_provedor"
    :aCols[4]:cSortOrder = "nombre_provedor"
    :aCols[5]:cSortOrder = "numero_factura"
   
    :oCol("Base"):nTotal            = oQry:sumabase
    :oCol("Exento"):nTotal      = oQry:sumaexento
    :oCol("Iva"):nTotal             = oQry:sumaiva
    :oCol("Total"):nTotal       = oQry:sumatotal
    :oCol("Retencion"):nTotal = oQry:sumaretenido
   
  END
 
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse

Postby albeiroval » Thu Jun 15, 2017 2:31 pm

Use FWH 17.04
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse

Postby albeiroval » Thu Jun 15, 2017 2:36 pm

Rick

The table has more than 1000 records

:(
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse

Postby nageswaragunupudi » Thu Jun 15, 2017 2:46 pm

Code: Select all  Expand view  RUN
                       SUM(montobase)          AS sumabase,
                        SUM(montototal)         AS sumatotal,
                        SUM(montoiva)           AS sumaiva,
                        SUM(montoretenido)  AS sumaretenido,
                        SUM(montoexento)        AS sumaexento
 

This should be a different query. Not a part of you main table query

Are you using modified xbrowse?
Regards

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

Re: Mr Rao, slow to create xbrowse

Postby albeiroval » Thu Jun 15, 2017 3:12 pm

Excellent Mr Rao !!

It works very well. :D

Are you using modified xbrowse?


I have not modified xbrowse.

I just made a new method to create filters with dolphin using this code :
Code: Select all  Expand view  RUN

EXTEND CLASS TXBrowse WITH METHOD QueryWithJoin

oBrw:QueryWithJoin( cQuery, TABLA_COMPRASFACTURAS, oQry )
 
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse

Postby nageswaragunupudi » Thu Jun 15, 2017 3:25 pm

It works very well. :D

Glad
Regards

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

Re: Mr Rao, slow to create xbrowse

Postby albeiroval » Thu Jun 15, 2017 3:50 pm

3) If you use FASTEDIT and do inline edit, the totals are automatically recalculated.


I do not use cell editing to add or modify records,
I use INSERT and UPDATE, oQry: Requery () to update the xbrowse data,
The problem now the totals do not update them.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Mr Rao, slow to create xbrowse(solved)... totals not update

Postby nageswaragunupudi » Thu Jun 15, 2017 4:20 pm

Yes, with dolphin and tmysql, even we modify one field we need to reload the entire data again.
That requires a browse refresh too. Anyway you are spending time for reloading the data. You spend a little more time requery totals query also and refresh the totals.

With fwmysql only the modified row is refreshed. You may try \fwh\samples\maria01.prg and check the edit behavior both inline and with dialog..
Regards

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

Re: Mr Rao, slow to create xbrowse(solved)... totals not update

Postby albeiroval » Thu Jun 15, 2017 6:21 pm

Rao,

Yes, I already did creating a query for totals and it works.
Thank you very much
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 380
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests