Question on 'ReadBuffer' property.

jpchausseau

Member²
I set the QueryAllRecords property of a TOracleDataSet to false, and its ReadBuffer property to 5. Then I linked a TDBGrid (through a TDataSource) to the OracleDataSet. The grid is able to display 50 records at a time.

When the connection to the database is activated (at runtime), the grid displays 50 records (not five). Does that mean that the ability of the grid to display 50 records overrides the 'ReadBuffer' property? How can I get assured that only 5 records at a time will be fetched from the database when the user scrolls through the grid?
 
New records will always be fetched to the client whenever the application requests them. This can be done programmatically (calling next, locate, last etc). When using a dbgrid, the grid will request as many records as it needs to fill in all visible rows in the form. I.e. if the grid initially is able to display 12 rows, it will do three fetches at once when you initiate the form (assuming the ReadBuffer is set to 5). It will continue fetching new rows whenever the user scrolls the grid.

So if you are using a grid that can show more than five rows at a time, I would think that increasing the ReadBuffer value gives you a better result. This leads to fewer network roundtrips back and forth getting your data.

Beware of long and lob fields, however, including such fields will lead to fetching just one row at a time.
 
Thank you for your concise answer. It neatly clears this issue for me.

Now, another (related) question: Let's suppose QueyAllRecords is set to false, and ReadBuffer=5 again. The dbGrid displays 5 rows at a time. Thus, after opening the dataSet 5 rows are fetched and displayed out of 100,000. If LAST is called, will only the last 5 rows of the table be fetched, or will ALL 100,000 records be fetched at once to allow displaying the 5 last ones?

Thanks again for your attention,
Jean-Paul
 
I think (but not really know) that calling LAST will only fetch the last few records of the table. All other behavior won't make sense ...

Oliver
 
No, all 100,000 records will be fetched. The TOracleDataSet cannot determine which 5 records are last without finishing the query. You should avoid such queries, and use explicit SQL statements to find specific records. Nobody needs 100,000 records in a grid
wink.gif
.

------------------
Marco Kalter
Allround Automations
 
Back
Top