views:

699

answers:

2

This query seems to be running incredibly slow (25 seconds for 4 million records!) on Sybase v10 at a clients database:

Select max(tnr) from myTable;

With tnr being the primary key.

If I run it 1000x on our server however, it seems to go fast (15 ms...) which makes me think it's because the query result is cached. Is there a way to disable the cache for this query (or entire database) in Sybase to reproduce this problem?

I tried:

call sa_flush_cache ();
call sa_flush_statistics ();

But didn't seem to do the trick.

A: 

Try dbcc cacheremove

Allethrin
Sadly, v10 doesn't seem to have a dbcc command.
Carra
+1  A: 

Unfortunately dbcc cacheremove will not work as it does not clear down the pages from cache but rather removes the descriptor and places it back on the free chain.

Aside from restarting the data server the only way to do this is to bind the object to a cache and then do your tests then unbind the object which will remove all the pages from cache.

Vincent