Trying to Quickly Open a Huge Table with Fdtable

Asked

Viewed 498 times

1

Hello, the problem I’m facing is: I have a table with 120,353 records need to make a general correction on the table and how hard I try FDTable.Active := True is in process endlessly... I’m using Firebird 2.5... What You Do?

table index

CREATE INDEX IDX_AND_PRO_AUX ON ANDAMENTOS_PROCESSUAIS(NUMERO_PROCESSO_AUX);

CREATE INDEX IDX_PUBLICACAO ON ANDAMENTOS_PROCESSUAIS(CODIGO_PUBLICACAO);

Would you have any way to open the table without loading all records?

  • 1

    what do you mean 'I need to make a general correction'? It’s a Edit to one/several existing records? A Insert?

  • 1

    It is why I opened the table by the system is slow and I need to fix this and the general question is why knowing how to repair I will see if it is applicable to the other tables in the dataModule.

  • 1

    But in your app you just want to open the table to show users a grid, or you want to browse the logs to make changes to the data by Fdtable (Fdtable.Edit, changes, Fdtable.Post)?

  • 1

    no use want... is the table itself... this happens when I open the system and at first I have to open 3 tables... DataModuleGeral.tbAndamentosConsulta.Open;
 DataModuleGeral.tbPublicacoesConsulta.Open;
 DataModuleGeral.tbAudienciasConsulta.Open;

  • 1

    no use want... is the table itself... this happens when I open the system and at first I have to open 3 tables... DataModuleGeral.tbAndamentosConsulta.Open;
 DataModuleGeral.tbPublicacoesConsulta.Open;
 DataModuleGeral.tbAudienciasConsulta.Open;,It takes about 50 seconds to 2 minutes to open...

  • You can use Fdquery’s to do virtually the same as Fdtable’s. The only difference is that instead of just saying the table name, you had to put the SQL Query there in Fdquery. But it turns out to be more flexible...

  • How’s the Mode property? Fdtable.FetchOptions.Mode

  • Table.FetchOptions.Mode := fmOnDemand

  • @If I was able to help with my answer, you can accept the answer by clicking on the left side of it. If you need any more help, let us know.

Show 4 more comments

2 answers

3

If you have grids associated with these FDTable, do the disableControls() to 'cut' the table-grids link before opening it usually speeds up quite.

Something like:

FDTable.DisableControls;
FDTable.Open;
FDTable.EnableControls;

To do as already suggested here, limit the number of records brought at a time FDTable you have to choose those options in the Fetchoptions of FDTable. There are a number of parameters you can use to speed up the reading of the table, but in this case I would say you need to edit the Mode for fmExactRecsMax and edit the value of Recsmax

But it is best to see the documentation in http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Fetching_Rows_(FireDAC)

  • 1

    I open the tables at the beginning of the system so I don’t have grids. I’m trying to configure this question of FetchOption more always raises an exception: ([Firedac][Phys][FB]-312. Exact fetch returned [1501] Rows, while [1500] was requested.)

2

If your goal is just to limit the number of records to open for example to 5,000 you only need to use the following code:

SELECT FIRST 5000 * FROM tabela ORDER BY id DESC;

Unlike the Mysql that we can use the Limit in the Firebird here we use the First.

Firebirdsql

  • 1

    Plus is a FDTable so much for a FDQuary can do that at FDTable ?

  • @Eduardomendonçadasilva I have no way to test because I don’t have Delphi installed, but there must be a way to associate Fdquery to Fdtable

  • 1

    in the system I work I have to open a 3 tables. These tables are the most used by users so not the biggest ones... I think the problem is that some fields of this table have the size of 8000 characters. as not system is not mine is the company where I work I stay sometimes without having what to do...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.