#1 2024-04-05 07:19:13

anouri
Member
Registered: 2024-02-11
Posts: 47

OrmTableDataSet.Close and OrmTableDataSet.Free is very slow

Hello and thanks.
The following statements are very slow, for a json that has 300 records. It takes a few seconds:

  DataSource1.DataSet := nil;

  OrmTableDataSet.Close;
  OrmTableDataSet.Free;
  
  OrmTableDataSet := TOrmTableDataSet.CreateFromJson(nil , json);
 
  DataSource1.DataSet := OrmTableDataSet;

Last edited by anouri (2024-04-05 07:31:58)

Offline

#2 2024-04-05 08:26:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: OrmTableDataSet.Close and OrmTableDataSet.Free is very slow

Try to debug a little and see where it is slow.
Close? Free? Assigning to DataSet? CreateFromJson?

Which compiler are you using?

My guess is it is in the VCL, not mORMot.
TOrmTableDataSet is just a wrapper around TDataSet with a TOrmTable which is very very fast (and daily validated/tested as such).

Offline

#3 2024-04-05 09:49:14

anouri
Member
Registered: 2024-02-11
Posts: 47

Re: OrmTableDataSet.Close and OrmTableDataSet.Free is very slow

I debugged it, closing is slow.

But you are right. I changed my code and sloved I don't khow why!!!!

    vwMain.BeginUpdate(); //cxgrid 
    //DataSource1.DataSet := nil;

Last edited by anouri (2024-04-05 10:03:08)

Offline

#4 2024-04-06 10:28:21

igors233
Member
Registered: 2012-09-10
Posts: 241

Re: OrmTableDataSet.Close and OrmTableDataSet.Free is very slow

Grid control is slow in adding records one by one, when you call BeginUpdate (and EndUpdate at the end) you're telling grid not to add/repaint record one by one but rather create all and then do a repaint. Perhaps a bit better (if you have multiple controls associated with table) Dataset.Disable(Enable)Controls
https://docwiki.embarcadero.com/Librari … leControls

Offline

#5 2024-04-10 17:45:38

anouri
Member
Registered: 2024-02-11
Posts: 47

Re: OrmTableDataSet.Close and OrmTableDataSet.Free is very slow

I know, but the interesting thing is why the speed is still low when datasource is set to nil. But when beginupdate is executed, the problem is solved.

Offline

Board footer

Powered by FluxBB