zoukankan      html  css  js  c++  java
  • Sybase Current Running SQL

    1.简单办法
    isql>SP_who2 找出spid

    isql>select * from master..sysprocesses 找出正在运行的sybase server进程
    isql>select SPID,SQLText from master..monProcessSQLText  找出SQL Text


    2. monitor系统表
    mon表中有两个表对于找出正在执行的SQL很有帮助: monProcessSQLText and monSysSQLText.

    monProcessSQLText  shows currently executing SQL
    monSysSQLText   shows recent, completed SQL
    monSysStatement   More information on completed SQL statements

    例子
    select * into #sqltext from monSysSQLText
    select * from #sqltext where SQLText like '%pt_sample%'
    结果
    SPID KPID ServerUserID BatchID  SequenceInBatch SQLText
    26 1900573 1 27 1 'select * from pt_sample s  pt_tx t where t.id = s.id'

    注意,mon表中的数据只能被select一次,ASE假设你只需要查看它一次,第二次select只会返回之后的数据。如果你要反复查看,那么把它select into到一个临时表中。

    更详细的信息
    SPID,KPID,DBID,ProcedureID,PlanID,BatchID,ContextID,LineNumber,CpuTime,WaitTime,MemUsageKB,PhysicalReads, LogicalReads,PagesModified,PacketsSent,PacketsReceived,NetworkPacketSize, PlansAltered,RowsAffected,ErrorStatus,HashKey,SsqlId,StartTime,EndTime

    25, 1900573,1,1280004560,30,12,2,0,0,0,684,0,0,0,0,0,2048,0,0,0,0,0,2008-11-15 10:03:14.793,2008-11-15 10:03:14.793
    我们得到了:
        Number of logical I/Os
        Number of physical I/Os
        Number of network packets sent/received
        Number of milliseconds of ‘waiting time’ during statement execution
        Start time & end time of execution
        
        

    3. Trace
    我们可以将当前session中所有的SQL都输出到一个文本文件中。
    isql>Set tracefile FILENAME [for spid]
    isql>set tracefile off [for spid]

    例子
    isql>Set tracefile ‘/opt/Sybase/tracefiles/2008 1101.trc12’ for 12
    如果不指定server process id, sybase系统将只记录当前session的SQL。
    记录的信息包括:
    SQL Text
    query plans (showplan output),
    statistics (statistics io output),
    show_sqltext (below!),
    set option show,
    dbcc traceon (100) output.

    执行Set tracefile 命令必须有sa or sso role, 并且grant了“set tracefile” permission



    4. set show_sqltext
    You can print the SQL text for ad-hoc queries, stored procedures, cursors, and dynamic prepared statements using set show_sqltext.

    Before you enable show_sqltext, you must first use dbcc (dbcc traceon(3604)) to instruct the server to send the output to your terminal instead of to standard output (i.e. to the console of the session that started up the ASE instance).
    The syntax for set show_sqltext is:
    set show_sqltext {on | off}

  • 相关阅读:
    动画,缩放
    本地公司
    调研 公司信息
    外贸 内贸 经商
    情感 爱情 恋爱
    H5源码
    世界 生活
    标识
    Jackson
    java数据结构
  • 原文地址:https://www.cnblogs.com/xzpp/p/2598166.html
Copyright © 2011-2022 走看看