Subject CalculateField being called too often
Author Joe
I recently switched a query component from TIBOQuery to TIB_Query. Since making the switch, there has been a huge performance problem. I have tracked it down to the fact that the OnCalculateField event is firing WAAAAAY too often. It seems like just about anything will cause this, but here's an example:

If open the dataset, and then scroll to the last record (using the "last record" button on the TIB_NavigationBar, my CalculateField handler gets called for EVERY SINGLE RECORD in the database, rather than just the last one. There is no need to calculate the fields for records that it's just skipping past. I found this out by putting a break point in my CalculateField handler, and it breaks there for every single record in the database. When it hits the breakpoint, this is what the call stack looks like:

TMainForm::OrderTableCalculateField
TIB_Statement::DoCalculateField
TIB_Row::CalculateFields
TIB_Row::RefreshBuffers
TIB_Dataset::SysFetchNext
TIB_Dataset::SysFetchAll
TIB_BDataset::SysLast
TIB_Dataset::Last
TIB_NavigationBar::BtnClick
...

I don't really know anything about IBO internals, but I'm guessing that it has something to do with that SysFetchAll call.

So...

Why does it fetch all of the records when I jump to the last record? How can I prevent this?

-Joe