If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Query regarding caching of data/index pages

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-10, 03:28
prsdkam prsdkam is offline
Registered User
 
Join Date: Jul 2010
Posts: 10
Query regarding caching of data/index pages

Hi all
I had a query regarding caching of data/index pages.The scenario is as follows:

For performance reasons I had to tune a porc where, within the code I found the bottle necked query which was consuming much more time than expected.
When I individually tried running the query for the first time the query took long time as expected but for consecutive runs(without doing any ammendments or changes) the query took comparitively less time than expected.
The conclusion that I could draw is--majority of the pages were present in the cache so the second run went for lesser number of physical reads.
(Please correct me if my understanding is incorrect)


So is there a way by which we can test our changes without having the impact/effect of cached pages which gives just an illusion of improved performance.



Thanking in advance for your time.


Prasad
Reply With Quote
  #2 (permalink)  
Old 08-13-10, 03:46
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
If you have isolated the select statement that's taking all the time then just use showplan to see how the number of logical reads alters when using your new query:
Code:
set showplan on
Your select stement
set showplan off
Alternatively just run a large select to clear out the cache before running your query:
Code:
select * from BigTable order by some_field
Your select statement
__________________
Mike
Reply With Quote
  #3 (permalink)  
Old 08-13-10, 04:23
agrawal.meet agrawal.meet is offline
Registered User
 
Join Date: Jun 2010
Posts: 51
When you are optimizing...your goal should be to reduce logical reads. Because, as you stated, after caching, Sybase just do logical reads and not physical reads. See query plan to know whether Indexes are being used or not.
Reply With Quote
  #4 (permalink)  
Old 08-13-10, 04:52
prsdkam prsdkam is offline
Registered User
 
Join Date: Jul 2010
Posts: 10
Thanks for the quick responce.
Yes I had seen the logical reads and they were greater than physical reads hence reached to the conclusion that the performance improvement was because of logial reads.

Now for me twiking the query would be secondary priority but before that I need to ensure that the changes that I would be doing and the performance improvemnt that I might see, should be the effect of the changes that I am doing and not because of the logical reads.

As mike suggested--
select * from BigTable(not included in my query) order by some_field

would be one approach of flushing the cache.

But is there any cleaner way/or any command to achieve the same

Thanks once again



Prasad
Reply With Quote
  #5 (permalink)  
Old 08-13-10, 05:04
agrawal.meet agrawal.meet is offline
Registered User
 
Join Date: Jun 2010
Posts: 51
you can bind a table to a cache. If you do this, if this table is already existing in the cache then it will flush all the pages.

SyBooks Online

Try it and let us know.
Reply With Quote
  #6 (permalink)  
Old 08-13-10, 07:40
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
As you stated you just need to reduce the number of logical reads - this is shown in the showplan output. Alternatively just provide the select statement and the index details of the tables involved and then we could either make some suggestions or point out any major issues.
__________________
Mike
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On