Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what exactly is CacheSize ?

Status
Not open for further replies.

RushiShroff

Programmer
Jan 23, 2002
216
IN
what is the cachesize property of Recordset object ?
 
penny1.gif
penny1.gif
 
Dear Paul,
Just see the explaination pasted below from above URL.
It seems hypothetical and theoritical.

The main question is, Same way I asked cursors/locktypes question, without using cachesize property what advantages I will gain compare to if I dont use it.


Devguru Explaination-->>
The CacheSize property sets or returns a long value that defines how many records can be stored in the local cache for the client. As you navigate through the Recordset, the cache will be continually refreshed. You can change the CacheSize any time the Recordset exists, but the contents in the cache will not be changed until the next retrieval from the database.

The default value is one record which means that only one record is fetched and cached at a time. For a large database, this is not too efficient and a larger value (especially in the 10 to 100 range) will speed up operations. On the negative side, records stored in a cache may not reflect real-time underlying changes being made to the database by other users. For example, your cache could contain records that have been recently deleted. Therefore, you may need to regularly call the Resync method which will also update the cache.

A cache size of zero is not permitted and will generate an error.

Code (VBScript):
rsChantList.CacheSize = 12

Rushi Shroff
 
I'm afraid I haven't used this property, and can only read into it what has been said by devGuru.

What I read is that if you are fetching a large amount of records, and plan to do a fair amount of work with them, then it appears if you set the cache size to the number of records in your recordset, then your performance will increase, as access to these records will be from cache memory, rather than normal memory, which is much much faster.

On the other hand, if you need your recordset to reflect real time changes to the database by other users (keep in mind you'll have to set your cursorType property to achieve this), then repeated .resync calls will have to be made in order to keep the recordset updated, which will hurt performance.

So, as always, it just depends on the application and what you plan to do with your recordset as to whether or not you wish to use this optional property, or just leave it at default, 1.

Good question, though. I think I'll begin trying to work this property into my applications, as it does appear to have the occasional performance advantage.

:)
paul
penny1.gif
penny1.gif
 
But dear Paul,
As in the article it is mentioned that..


So now you’re thinking… “Well, if I don’t have an active connection to the database, why even bother setting the locktype, since it’s not going to have any real effect on the database, itself”, right? True enough, BUT if you don’t set a locktype, then you have accepted the default of adLockReadOnly, and therefore you cannot update it. Don’t want to update it, you say? Fine, then… don’t set it. See how easy this is? You just have to think about all the things that you want to do with your recordset, and the proper attributes will simply present themselves.


Generally I dont declare lock type explicitly and still I am able to UPDATE my records.That is the question revolving in my mind since long.

Please answer.

Rushi Shroff
 
Hmmm... interesting. I would be interested in seeing some code where you open a recordset with default properties, update a field, and call .update() on the recordset.

paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top