Search code examples
databasecachingsap-ase

How to Clear Cache in Sybase ASE


I want to clear the cache of Sybase ASE, so that I can test always the worst case scenario in two different queries.

What I found in my research was to use the commands below to clear cache, and sp_helpcache to check objects cached:

sp_unbindcache <dbname>, <table>
sp_unbindcache_all <cache name>

How did I tested it?

I ran a SELECT Count on a table before and after running sp_unbindcache and the second test was to run the query before and after sp_unbindcache_all

What happened?

The first time I ran the query there was physical I/O the subsequent tries did not, only Logical I/O. (Cache preserved despite running the unbindcache commands)

Weird Stuff

When I ran sp_helpcache it didn't show my table on the list of objects in Cache Binding Information (CBI). After running sp_unbindcache_all, sp_helpcache showed no rows on CBI. I then re-run the query and sp_helpcache was still with CBI empty. This is weird because it might mean that when I run a query, my table is cache somewhere else.

The Question

So I would Like to know how can I find where my table is being cached when I run a query, and then how can I clear it from there?

Other Info

Database: SYBASE ASE 15.7

sp_helpcache only shows "default data cache"

Cache Binding Information(CBI) - is part of sp_helpcache's output

UPDATE:

I Have made a new test where I Bind the table to the "default data cache" to see if it would appear in CBI and it appeared.


Solution

    • To clear cache in "default data cache" you should use dbcc cachedataremove
    • for user defined cache you should use sp_unbindcache , or sp_unbindcache_all