AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 39297
Accepted
Kin Shah
Kin Shah
Asked: 2013-04-05 14:13:43 +0800 CST2013-04-05 14:13:43 +0800 CST 2013-04-05 14:13:43 +0800 CST

Sybase SQL - 发生截断错误。命令已中止并找到缓存质量

  • 772

需要以下代码的帮助,因为它因截断错误而失败

发生截断错误。命令已中止。

create table monCacheQuality (
        ServerName sysname
        ,CollectionDateTime smalldatetime not null
        ,PhysicalWrites decimal(15, 0) not null
        ,PhysicalReads decimal(15, 0) not null
        ,LogicalReads decimal(15, 0) not null
        ,CacheQuality decimal(15, 0) not null
        ,CacheHitPct decimal(15,4) not null
        )

-- Main code starts here 
declare @physical_read1 decimal(15, 0)
    ,@logical_read1 decimal(15, 0)
    ,@physical_write1 decimal(15, 0)
    ,@cache_search1 decimal (15,4)

declare @physical_read2 decimal(15, 0)
    ,@logical_read2 decimal(15, 0)
    ,@physical_write2 decimal(15, 0)
    ,@cache_search2 decimal (15,4)

while (1=1)
begin
    select @physical_write1 = PhysicalWrites
        ,@physical_read1 = PhysicalReads
        ,@logical_read1 = LogicalReads
        ,@cache_search1 = CacheSearches
    from master..monDataCache

    waitfor delay '00:00:20' -- Log every 20 sec

    select @physical_write2 = PhysicalWrites
        ,@physical_read2 = PhysicalReads
        ,@logical_read2 = LogicalReads
        ,@cache_search2 = CacheSearches
    from master..monDataCache

    insert monCacheQuality
    select @@servername as ServerName
        ,getUTCdate()
        ,@physical_write2 - @physical_write1
        ,@physical_read2 - @physical_read1
        ,@logical_read2 - @logical_read1
        ,case 
            when @physical_read2 - @physical_read1 = 0
                then - 1
            else (@logical_read2 - @logical_read1) / (@physical_read2 - @physical_read1)
            end as CacheQuality
        ,100-(((@physical_read2-@physical_read1)/(@cache_search2-@cache_search1))*100) as CacheHitPct
end
sybase sybase-ase
  • 1 1 个回答
  • 5227 Views

1 个回答

  • Voted
  1. Best Answer
    Kin Shah
    2013-07-27T13:02:33+08:002013-07-27T13:02:33+08:00

    以防万一有人想为 Sybase ASE 15 及更高版本设置缓存质量,以下脚本将有所帮助:

    脚本的更改可以快速运行而无需查询 MDA 表的开销,并且通过切换到int数据类型来解决截断问题。:

    • 现在,where 子句使脚本在 Sybase ASE 负载过重时工作。在哪里CacheID = 0
    • 最后一个更改只是物理读取 = 0 时的逻辑更改,这样我们就保存了逻辑读取。then @logical_read2 - @logical_read1

          -- CREATE A TABLE FOR DURATION SIMULATION
          if not exists(select 1 from sysobjects where name = 'TimeControl')
          begin
            create table TimeControl (counter int)
          end
          go
      
          -- CREATE TABLE FOR SQL PIPE RESULTS
          if not exists(select 1 from sysobjects where name = 'monCacheQuality')
          begin
            create table monCacheQuality (
            ServerName sysname
            ,CollectionDateTime smalldatetime not null
            ,PhysicalWrites decimal(15, 0) not null
            ,PhysicalReads decimal(15, 0) not null
            ,LogicalReads decimal(15, 0) not null
            ,CacheQuality decimal(15, 0) not null
            )
          end
          go
          create table cache_Begin (
        CacheID int not null,
        InstanceID tinyint not null,
        RelaxedReplacement int not null,
        BufferPools int not null,
        CacheSearches int not null,
        PhysicalReads int not null,
        LogicalReads int not null,
        PhysicalWrites int not null,
        Stalls int not null,
        CachePartitions smallint not null,
        CacheName varchar(30) null
      )
      go
      create table cache_End (
        CacheID int not null,
        InstanceID tinyint not null,
        RelaxedReplacement int not null,
        BufferPools int not null,
        CacheSearches int not null,
        PhysicalReads int not null,
        LogicalReads int not null,
        PhysicalWrites int not null,
        Stalls int not null,
        CachePartitions smallint not null,
        CacheName varchar(30) null
      )
      go
      
      use tempdb --- change this to be other than the db being monitored !!
      go
      
      declare @physical_read1 int
            ,@logical_read1 int
            ,@physical_write1 int
      declare @physical_read2 int
            ,@logical_read2 int
            ,@physical_write2 int
      
      while (select counter from TimeControl) =1 
      begin
            select @physical_write1 = PhysicalWrites
                  ,@physical_read1 = PhysicalReads
                  ,@logical_read1 = LogicalReads
            from master..monDataCache
            where CacheID = 0
      
            waitfor delay '00:01:00'
      
            select @physical_write2 = PhysicalWrites
                  ,@physical_read2 = PhysicalReads
                  ,@logical_read2 = LogicalReads
            from master..monDataCache
            where CacheID = 0
      
            insert monCacheQuality
            select @@servername as ServerName
                  ,getUTCdate()
                  ,@physical_write2 - @physical_write1
                  ,@physical_read2 - @physical_read1
                  ,@logical_read2 - @logical_read1
                  ,case 
                        when @physical_read2 - @physical_read1 = 0
                              then @logical_read2 - @logical_read1
                        else (@logical_read2 - @logical_read1) / (@physical_read2 - @physical_read1)
                        end as CacheQuality
      end
      
      
      -- Report the data that is collected.........
      select *
      from monCacheQuality
      
      
      
      
      
      
      
      
      ---- reset it back ... (in another Query window)
      update TimeControl 
      set counter = 0 
      go
      
      
      
      
      --- cleanup ... start and end cache table for next reuse 
      drop table cache_Begin
      go
      
      
      
      
      drop table cache_End
      go
      
    • 0

相关问题

  • 固定值字段的外键约束

  • 为什么同时使用 TRUNCATE 和 DROP?

  • 已经连接时是否有与 isql 等效的 -w ?

  • 如何从 isql 将参数传递给“SQL 脚本”

  • 如何识别具有指向 Sybase 中特定表的外键的表?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    授予用户对所有表的访问权限

    • 5 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    pedrosanta 使用 psql 列出数据库权限 2011-08-04 11:01:21 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve