Page 1 of 1

FindNext and Next

Posted: Tue 20 Sep 2011 12:52
by colutti
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?

Posted: Tue 20 Sep 2011 14:56
by AndreyZ
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.

Posted: Tue 20 Sep 2011 16:12
by colutti
I have no filters set at all and despite that FindNext is a lot more slower than Next.

Posted: Wed 21 Sep 2011 12:14
by AndreyZ
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.