cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Troubleshooting Sybase ASE performance issues

MelCalucin
Participant
0 Likes
5,369

I'm new to Sybase ASE, but I had been a DBA for MS SQL Server in previous jobs. I'm now one of the development managers for SAP Data Services which using Sybase ASE. Note, I'm not the basis person for Data Services. The Data Services servers and corresponding Sybase ASE server are hosted by a PaaS provider.

At times, Data Services becomes inaccessible. I can't get to Data Services CMC or the Data Services Management Console.

The PaaS provider is telling us a bad query is impacting the Sybase ASE server. I've asked them what database and what tables are being queried, but I never get an answer from them. I know I can determine this from MS SQL Server, but is it possible to identify what query is causing the issue in Sybase ASE? If so, what is the process of determining this?

Thanks.

View Entire Topic
sladebe
Active Participant

One easy thing to check is to see if a resource is getting used up. Use:

sp_monitorconfig "all"

If you're looking for a bad query, you can use mon tables, but there are a lot of them. Here's a basic query I use for live monitoring (ie. for currently running queries):

set nocount on
go
set flushmessage on
go
select * into #old from monProcessActivity
waitfor delay "00:00:05"
select * into #new from monProcessActivity
while(1=1)
begin
  select new.SPID, login=suser_name(new.ServerUserID),
         CPUTime=new.CPUTime-old.CPUTime,
         PhysicalReads=new.PhysicalReads-old.PhysicalReads, LogicalReads=new.LogicalReads-old.LogicalReads,
         PhysicalWrites=new.PhysicalWrites-old.PhysicalWrites, new.LocksHeld
         from #old old, #new new
         where old.SPID=new.SPID and old.KPID=new.KPID
         and ( new.CPUTime-old.CPUTime>0 or new.PhysicalReads-old.PhysicalReads>0 or
               new.LogicalReads-old.LogicalReads>0 or new.PhysicalWrites-old.PhysicalWrites>0 )
         order by new.CPUTime-old.CPUTime desc

  truncate table #old
  insert into #old select * from #new
  truncate table #new
  waitfor delay "00:00:05"
  -- Whoops, missed this line.  Added in a later edit:
  insert into #new select * from monProcessActivity
end
go

You can also use monProcessSQLText to see what SQL is running for a given spid (make sure to sort by SPID,BatchID, LineNumber SequenceInLine)

If you want to look at historical data, it's a little more complicated. You can use monCachedProcedures to see accumulated stats for cached procedures (stats go away if the stored proc gets pushed out of cache. There can be multiple cached copies of the same stored proc). There's also monCachedStatement, but you have to have the statement cache enabled for this to work. Cached statements can sometimes have "needs to be recompiled" type side effects (cached statement scans when it shouldn't)

MelCalucin
Participant
0 Likes

This is awesome!

I'll give this a try.

Thanks.

-Mel

former_member89972
Active Contributor

Mel You have to add :

"insert into #new select * from monProcessActivity"

after

truncate table #new

inside the while loop to make the code Ben work !

You may also want to do "set flushmessage on" to get the outputs out quickly.

HTH Avinash

sladebe
Active Participant
0 Likes

Ooops. Thanks for the correction.