Page 1 of 1

Performance issues and a bug

Posted: Sat Apr 22, 2023 11:16 am
by 18692679
I'm working with a TDataset that contains 100,000 records. I noticed some a performance issue and while resolving it I also noticed a bug.

1. I'm using TZMemTable (zeoslib 8.0) which is a in memory TDataset (i.e. all the records are loaded into the memory)
2. I noticed that every time the grid access the TZMemdataSet, TVirtualDBData.FetchAllRecords is being called. This is clearly not needed.
3. Internally the grid calls FetchAllRecords If Not IBuffered (in TVirtualDBData.InternalRefresh)
4. However! IBuffered can only be set *after* TVirtualDBData is created by TVirtualDBData.Form (so there is at least 1 call for FetchAllRecords)
5. But there is a bug, the grid behaves funny, and scrolling doesn't work because that TVirtualDBData.KnownCount returns *false* when IBuffered is true!

So in-order to make everything works fast I had to change 2 function:
1. TVirtualDBData.KnownCount should return True for IBuffered
2. in TVirtualDBData.From set IBuffered directly (using SetFetchMode calls a Refresh and I didn't have time to check what it does)

Thanks,

I'm using: windows 10, Lazarus 2.2.4, Grid 1.1