FindNext and Next

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
colutti
Posts: 6
Joined: Wed 08 Jun 2011 21:06

FindNext and Next

Post by colutti » Tue 20 Sep 2011 12:52

When opening a table with ~800,000 lines with FetchAll := True (i know i should set FetchAll to false, but i cant) I noticed that FindNext is slower than Next. But on the other hand, FindNext consumes a lot less memory than Next. Why does that happen? Which one should I use and what are the differences between them?

AndreyZ

Post by AndreyZ » Tue 20 Sep 2011 14:56

Hello,

The FindNext method is used for positioning the dataset on the next record, respecting any filters. This method takes into consideration any filters that are in effect, and that's why it can be slower than the Next method. The Next method moves cursor to the next record in the dataset. If you are working with FetchAll=True, both methods don't allocate any memory. In this case all memory is allocated when you open a table. You can find more information about these methods in the Delphi documentation.

colutti
Posts: 6
Joined: Wed 08 Jun 2011 21:06

Post by colutti » Tue 20 Sep 2011 16:12

I have no filters set at all and despite that FindNext is a lot more slower than Next.

AndreyZ

Post by AndreyZ » Wed 21 Sep 2011 12:14

The FindNext method looks for the next record, and the Next method moves cursor to the next position in a dataset only. That is the difference between these methods that makes the FindNext method slower than the Next method.

Post Reply