AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / dba / Perguntas / 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 - Ocorreu um erro de truncamento. O comando foi abortado e encontra CACHE QUALITY

  • 772

Precisa de ajuda com o código abaixo, pois falha com erro de truncamento

Ocorreu um erro de truncamento. O comando foi abortado.

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 respostas
  • 5227 Views

1 respostas

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

    Caso alguém queira configurar a CACHE QUALITY para Sybase ASE 15 e superior, o script abaixo ajudará:

    Mudanças para que o script funcione rápido sem sobrecarga de consultar tabelas MDA e o problema de truncamento é resolvido ao mudar para tipo de intdados.:

    • A cláusula where agora faz o script funcionar quando o Sybase ASE está sob cargas pesadas. OndeCacheID = 0
    • A última alteração é apenas uma alteração lógica para quando leituras físicas = 0, assim salvamos as leituras lógicas.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

relate perguntas

  • Restrição de chave estrangeira no campo de valor fixo

  • Por que usar TRUNCATE e DROP?

  • Existe um -w equivalente para isql quando já conectado?

  • Como posso passar parâmetros para um "Script SQL" do isql

  • Como identifico tabelas que possuem uma chave estrangeira para uma tabela específica no Sybase?

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Como fazer a saída do sqlplus aparecer em uma linha?

    • 3 respostas
  • Marko Smith

    Selecione qual tem data máxima ou data mais recente

    • 3 respostas
  • Marko Smith

    Como faço para listar todos os esquemas no PostgreSQL?

    • 4 respostas
  • Marko Smith

    Conceder acesso a todas as tabelas para um usuário

    • 5 respostas
  • Marko Smith

    Listar todas as colunas de uma tabela especificada

    • 5 respostas
  • Marko Smith

    Como usar o sqlplus para se conectar a um banco de dados Oracle localizado em outro host sem modificar meu próprio tnsnames.ora

    • 4 respostas
  • Marko Smith

    Como você mysqldump tabela (s) específica (s)?

    • 4 respostas
  • Marko Smith

    Listar os privilégios do banco de dados usando o psql

    • 10 respostas
  • Marko Smith

    Como inserir valores em uma tabela de uma consulta de seleção no PostgreSQL?

    • 4 respostas
  • Marko Smith

    Como faço para listar todos os bancos de dados e tabelas usando o psql?

    • 7 respostas
  • Martin Hope
    Stéphane Como faço para listar todos os esquemas no PostgreSQL? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh Por que o log de transações continua crescendo ou fica sem espaço? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland Listar todas as colunas de uma tabela especificada 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney O MySQL pode realizar consultas razoavelmente em bilhões de linhas? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx Como posso monitorar o andamento de uma importação de um arquivo .sql grande? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison Como você mysqldump tabela (s) específica (s)? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    pedrosanta Listar os privilégios do banco de dados usando o psql 2011-08-04 11:01:21 +0800 CST
  • Martin Hope
    Jonas Como posso cronometrar consultas SQL usando psql? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas Como inserir valores em uma tabela de uma consulta de seleção no PostgreSQL? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas Como faço para listar todos os bancos de dados e tabelas usando o psql? 2011-02-18 00:45:49 +0800 CST

Hot tag

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

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve