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 > Stored Proc Optimizing

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-10, 12:53
alirulez999 alirulez999 is offline
Registered User
 
Join Date: Jan 2010
Posts: 25
Stored Proc Optimizing

Suddenly one of the stored proc becomes very slow. When checked the query plan came to know that 2 tables are not using indexes. Used sp_compiled and also dropped and recreated the proc. But still the optimizer is not using the desired indexes. Does not want to force the index. Wanted to know the root cause of optimizer not using the index. please help.
Reply With Quote
  #2 (permalink)  
Old 02-03-10, 03:43
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,258
Have you updated statistics for the 2 tables?
Reply With Quote
  #3 (permalink)  
Old 02-03-10, 16:45
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,781
pdreyer has an excellent point about the statistics. You should probably also check to see if there are border cases in your data. Are there any combination of parameters the stored procedure accepts that cause a table scan to be preferable? Typically, RDBMS systems only use indexes at 4 - 7 % selectivity.
Reply With Quote
  #4 (permalink)  
Old 02-07-10, 01:26
alirulez999 alirulez999 is offline
Registered User
 
Join Date: Jan 2010
Posts: 25
update statistics are actually run every weekend using a batch. But still there are no sign of any change with the query plan.
Reply With Quote
  #5 (permalink)  
Old 02-07-10, 10:48
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,517
Can you add timing statements to find where in the proc it is suddenly taking the time and then give us the SQL at this point. Perhaps another batch is now locking a table when it wasn't before - have any batches been added/changed recently? Have you tried just running the proc and seeing if it runs slow at all times? Do the tables concerned always have a moderate amount of data in them or could one particular table be empty when the statistics are built and so affect stored proc plans?

Mike
Reply With Quote
Reply

Tags
index, optimizing, stored proc

Thread Tools
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