简体   繁体   English

FireDac FDTable 延迟打开/获取记录

[英]FireDac FDTable Delay Open/Fetch records

For some reason, I need to use FDTable in a Delphi Project to Fetch a large number of records (Interbase Database), unfortunately, to open the FDTable takes too much time (up to 2min and sometimes more) even worse when to ApplyUpdate, I tried everything possible by changing the fetch options: Recsmax, Rowsize, Mode, etc. as mention on some pages, Like: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Fetching_Rows_(FireDAC)出于某种原因,我需要在 Delphi 项目中使用 FDTable 来获取大量记录(Interbase 数据库),不幸的是,打开 FDTable 需要花费太多时间(长达 2 分钟,有时甚至更多),更糟糕的是,当应用更新时,我通过更改获取选项尝试了一切可能:Recsmax、Rowsize、Mode 等,如某些页面上所述,例如: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Fetching_Rows_(FireDAC)

Set the RecsMax Option to a small value (50 or 100) helps a lot with the performance but it will not fetch 1 record with Filter applied even with FetchAll.将 RecsMax 选项设置为一个较小的值(50 或 100)对性能有很大帮助,但即使使用 FetchAll,它也不会在应用过滤器的情况下获取 1 条记录。 As I mention before I need to do this with FDtable, FDQuery is not an option as we all know dealing with queries is better.正如我在需要使用 FDtable 执行此操作之前提到的,FDQuery 不是一个选项,因为我们都知道处理查询更好。

Is there a recommendation to smoothly open and fetch the data (100k+ records)?是否有平滑打开和获取数据(100k+ 条记录)的建议? It's Possible to fetch records with Filter + RecsMax?可以使用Filter + RecsMax 获取记录吗?

The query table must have Primary key.查询表必须有主键。 You can configure TFDTable as follows您可以按如下方式配置 TFDTable

  FDTable1.FetchOptions.Items := [fiMeta];  // at least
  FDTable1.FetchOptions.Unidirectional := False;
  FDTable1.FetchOptions.CursorKind := ckAutomatic; // or ckDynamic
  FDTable1.CachedUpdates := False;
  // LiveWindowParanoic
  // When it is false there are problems with Locate and Recno
  FDTable1.FetchOptions.LiveWindowParanoic := False // Play with True/False.

This is the configuration for the best performance这是最佳性能的配置

FDTable component is there mainly for BDE compatibility. FDTable 组件主要用于 BDE 兼容性。

FDQuery with "select * from Table1" is exactly the same thing as using FDTable, but you can filter resultset on server side.带有“select * from Table1”的 FDQuery 与使用 FDTable 完全相同,但您可以在服务器端过滤结果集。

100k+ records is a lot of data to transfer, blobs add additional overhead, as they're usually fetched separately. 100k+ 条记录是要传输的大量数据,blob 会增加额外的开销,因为它们通常是单独获取的。 I suggest you rethink the functionality design.我建议你重新考虑功能设计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM