블로그 이미지
보미아빠

카테고리

보미아빠, 석이 (528)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total
Today
Yesterday

달력

« » 2025.9
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

공지사항

최근에 올라온 글

cpu 사용량

카테고리 없음 / 2012. 1. 1. 01:07

alter view cpu_percent
as
select
 top 256 record_id,
 dateadd(ms, -1 * ( (select cpu_ticks / convert(float, ms_ticks) from sys.dm_os_sys_info) - [timestamp]), GetDate()) as EventTime,
 SQLProcessUtilization,
 SystemIdle,
 100 - SystemIdle - SQLProcessUtilization as OtherProcessUtilization
 -- system idle 값과 SQLProcessUtilization 값을 이용해서 SQL 외 cpu 사용율을 계산 합니다.
from (
  select
   record.value('(./Record/@id)[1]', 'int') as record_id,
   record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') as SystemIdle,
   record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') as SQLProcessUtilization,
   timestamp
  from (
   select timestamp, convert(xml, record) as record
   from sys.dm_os_ring_buffers
   where ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR'
   and record like '%<SystemHealth>%'
   ) as x
 ) as y
order by record_id asc
Posted by 보미아빠
, |

Improvements for the DBCC CHECKDB command may result in faster performance when you use the PHYSICAL_ONLY option

sql server 2008r2 cu11 이나 sp1 cu4 를 설치하면 Traceflag 2562 와 2549 를 통해서 physical only 옵션을 사용할 수 있고 이는 꼭 checkdb 를 해서 체크를 해야 하는 경우에는 빠르게 체크 할 수 있다. 보통 checkdb 는 백업/복구를 통해서 다른 서버에서 진행 하는것이 관례이나 어떤 이유에서 실제 서버에서 꼭 해봐야 하는 경우에는 유용 할 수 있다. 

데이터베이스는 너무크고, 리스토어 할 시스템은 없고 주기적으로 일관성체크는 해봐야 하는 시스템에서는 유용할 수 있다.
sql server 2008 용은 내년에 만들어 준단다. (지금은 2011년 12월 31일 입니다.)

http://support.microsoft.com/kb/2634571
Posted by 보미아빠
, |
http://msdn.microsoft.com/en-us/library/ms144259(v=sql.90).aspx#options

다양한 삭제가 가능함.

[REMOVE]

The REMOVE parameter specifies which components to uninstall, like SQL Server, Reporting Services, or Analysis Services. This command must be used in conjunction with the INSTANCENAME parameter. For example, to remove the instance aware component AND any non-instance aware components, such as Client_Components, you would specify the following:

  • REMOVE=All INSTANCENAME=MSSQLSERVER
    ms144259.note(en-US,SQL.90).gifImportant:
    Do not use this parameter if you have several instances installed and you still want to use client tools.

    To remove all non-instance aware components, such as Client_Components and SQL_DTS, specify REMOVE=ALL without reference to the instance name.
    When REMOVE is specified for a new installation, components listed after 'REMOVE=' are not included for installation. For example, to install every component except for Reporting Services components during a new installation specify the following:
    • ADDLOCAL=All REMOVE=RS_Server,RS_Web_Interface

REMOVE can also be used during maintenance to remove components from an existing installation. For example, to remove Full-Text Search, specify the following:

  • REMOVE=SQL_FullText
    ms144259.note(en-US,SQL.90).gifImportant:
    Removing the parent feature removes both the parent and the child feature.

    REMOVE=
    

Posted by 보미아빠
, |
네트웍 관련 CPU 워크로드 분산 및 튜닝 포인트

1. RSS 활성화 및 셋팅 (많은 CORE 로 네터웍 부하를 분산) http://minimonk.tistory.com/2728
2. base filtering engine 을 끈다? 그럼 방화벽 관련 문제가 있지만 성능 위주의 튜닝이 필요한 경우 활성화 (패킷필터를 하지마)
3. TCP Chimmeny offload 를 활성화 (네트웍 데이터패킷 처리 일부를 NIC 가 처리)
   http://support.microsoft.com/kb/942861/ko 드라이버를 최신으로 올리고 하던지 인텔 쓰던지.....

좋은 기능들 이지만 많은 문제가 있으니 죽어도 활성화 해야 하는 경우 빼고는 disable 을 권장한다. -_-
cpu 1% 쓰면서 네트웍 튜닝 한다고 저런 옵션 설정하면 바로 기때기다.....
Posted by 보미아빠
, |
Posted by 보미아빠
, |

커서 선택

카테고리 없음 / 2011. 12. 19. 06:11

커서 유형 선택

커서 유형 선택은 다음을 비롯한 여러 변수에 따라 달라집니다.

  • 결과 집합의 크기

  • 필요한 데이터 비율

  • 열린 커서의 성능

  • 스크롤이나 업데이트 등과 같은 커서 작업의 필요성

  • 다른 사용자가 수행하는 데이터 수정의 가시성 수준

커서 유형을 선택할 때 따라야 하는 몇 가지 규칙은 다음과 같습니다.

  • 기본 테이블 및 정방향 전용 커서는 정적 커서 또는 키 집합 커서보다 빨리 열립니다. 정적 커서 및 키 집합 커서가 열린 경우 내부 임시 작업 테이블을 작성해야 하지만 기본 테이블 및 정방향 전용 커서에는 이러한 테이블이 필요하지 않습니다.

  • 정적 및 키 집합 커서의 경우 임시 데이터베이스의 사용량이 늘어납니다. 정적 서버 커서는 임시 데이터베이스에 전체 커서를 작성합니다. 키 집합 커서는 임시 데이터베이스에 키 집합을 작성합니다.

  • 프로젝션이나 선택 없이 기본 테이블을 있는 그대로 검색할 경우에는 최소한의 오버헤드를 가지는 기본 테이블 커서를 사용하는 것이 좋습니다.

  • 정적 커서는 데이터를 복제하기 때문에 가장 많은 리소스를 소비합니다.

Posted by 보미아빠
, |


hash join 으로 풀리나 merge join 이 발생하도록 하고 planguide 로 고정 시켰다.
음 이러한 planguide 는 cursor 계획에도 적용 가능하다.
커서는 실행계획이 일반 쿼리 계획과 다르게 나올 수 있다.
커서 타입이나 락 타입 로케이션 등에 따라 다양하게 플랜이 바뀔 수 있고, 이때 비 효율적인 플랜이 선택 된다면
planguide 로 어플리케이션 변경없이 플랜을 가이드 할 수 있다.
또한 fn_validate_plan_guide 를 이용해 planguide 가 에러가 나면, 에러의 원인을 알 수 있다.

요지는 rule 컨트롤로 쿼리 변경 없이 plan 을 만들어 내고 고정 할 수 있다는 것이다.

if object_id ('tblx') is not null
drop table tblx
go

if object_id ('tbly') is not null
drop table tbly
go

create table tblx (cint int, cvarchar varchar(100))
create table tbly (cint int, cvarchar varchar(100))

dbcc freeproccache
go
drop table t_before
go
drop table t_after
go

select * into t_before from sys.dm_exec_query_transformation_stats
go

select * from tblx a join tblx b on a.cint = b.cint where a.cint < 1
go

select * into t_after from sys.dm_exec_query_transformation_stats
go

select *
  from t_before a
  join t_after b
    on a.name = b.name
   and a.succeeded <> b.succeeded
go

dbcc ruleoff('JNtoHS')
-- 플랜을 프로파일러에서 받아내고,
dbcc ruleon('JNtoHS')
-- 받아낸 플랜을 적용하고 다시 룰을 원상 복구한다.
-- 복구된 상황에서 플랜 가이드에 의해 올바르게 의도한 플랜으로 풀렸는지 확인한다.

exec sp_create_plan_guide
@name = N'Guide',
@stmt = N'select * from tblx a join tblx b on a.cint = b.cint where a.cint < 1',
@type = N'SQL',
@module_or_batch = NULL,
@params = NULL,
@hints = N'OPTION(USE PLAN N''<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.1" Build="10.50.2500.0"><BatchSequence><Batch><Statements><StmtSimple><QueryPlan CachedPlanSize="24" CompileTime="2" CompileCPU="2" CompileMemory="160"><RelOp NodeId="0" PhysicalOp="Merge Join" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0.000313" EstimateCPU="0.00564738" AvgRowSize="121" EstimatedTotalSubtreeCost="0.0352532" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cvarchar"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cvarchar"/></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="0" ActualExecutions="0"/></RunTimeInformation><Merge ManyToMany="1"><InnerSideJoinColumns><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/></InnerSideJoinColumns><OuterSideJoinColumns><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/></OuterSideJoinColumns><Residual><ScalarOperator ScalarString="[SQLTAG2008R2].[dbo].[tblx].[cint] as [b].[cint]=[SQLTAG2008R2].[dbo].[tblx].[cint] as [a].[cint]"><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/></Identifier></ScalarOperator><ScalarOperator><Identifier><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/></Identifier></ScalarOperator></Compare></ScalarOperator></Residual><RelOp NodeId="1" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="1" EstimateIO="0.0112613" EstimateCPU="0.000100065" AvgRowSize="65" EstimatedTotalSubtreeCost="0.0146449" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cvarchar"/></OutputList><MemoryFractions Input="1" Output="0.5"/><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" ActualRebinds="0" ActualRewinds="0" ActualEndOfScans="0" ActualExecutions="0"/></RunTimeInformation><Sort Distinct="0"><OrderBy><OrderByColumn Ascending="1"><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/></OrderByColumn></OrderBy><RelOp NodeId="2" PhysicalOp="Table Scan" LogicalOp="Table Scan" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="65" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cvarchar"/></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="0" ActualExecutions="0"/></RunTimeInformation><TableScan Ordered="0" ForcedIndex="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/></DefinedValue><DefinedValue><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cvarchar"/></DefinedValue></DefinedValues><Object Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" IndexKind="Heap"/><Predicate><ScalarOperator ScalarString="[SQLTAG2008R2].[dbo].[tblx].[cint] as [b].[cint]&lt;(1)"><Compare CompareOp="LT"><ScalarOperator><Identifier><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[b]" Column="cint"/></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(1)"/></ScalarOperator></Compare></ScalarOperator></Predicate></TableScan></RelOp></Sort></RelOp><RelOp NodeId="3" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="1" EstimateIO="0.0112613" EstimateCPU="0.000100065" AvgRowSize="65" EstimatedTotalSubtreeCost="0.0146449" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cvarchar"/></OutputList><MemoryFractions Input="0.5" Output="0.5"/><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" ActualRebinds="0" ActualRewinds="0" ActualEndOfScans="0" ActualExecutions="0"/></RunTimeInformation><Sort Distinct="0"><OrderBy><OrderByColumn Ascending="1"><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/></OrderByColumn></OrderBy><RelOp NodeId="4" PhysicalOp="Table Scan" LogicalOp="Table Scan" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="65" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cvarchar"/></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" ActualEndOfScans="0" ActualExecutions="0"/></RunTimeInformation><TableScan Ordered="0" ForcedIndex="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/></DefinedValue><DefinedValue><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cvarchar"/></DefinedValue></DefinedValues><Object Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" IndexKind="Heap"/><Predicate><ScalarOperator ScalarString="[SQLTAG2008R2].[dbo].[tblx].[cint] as [a].[cint]&lt;(1)"><Compare CompareOp="LT"><ScalarOperator><Identifier><ColumnReference Database="[SQLTAG2008R2]" Schema="[dbo]" Table="[tblx]" Alias="[a]" Column="cint"/></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(1)"/></ScalarOperator></Compare></ScalarOperator></Predicate></TableScan></RelOp></Sort></RelOp></Merge></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>'')'

select plan_guide_id from sys.plan_guides
select * from sys.fn_validate_plan_guide(65545)
EXEC sp_control_plan_guide N'DROP', N'Guide'


option (loop join, table hint (th_, index(d_1f0000018000000f), forceseek))
술한잔 벌었다......으흐흐흐흐

Posted by 보미아빠
, |
Posted by 보미아빠
, |
Posted by 보미아빠
, |

이유는 정말 그렇게 여러 쓰레드로 쏘면 안되는 경우가 구독데이터세이스에 있기 때문이다.

외래키 제약 조건
클러스터되지 않은 고유 인덱스
인덱싱된 뷰
DML 트리거

이것을 에러 날때 마다 복제 에이전트를 폴링 하다가 다시 살려주는 (20초 간격으로 세션을 조사해보고 혼자 돌고 있으면 여러 복제 에이전트 재시작) work-around 를 쓸 수도 있지만 PK-FK 관계를 복제 구독에서 꼭 유지 하지 않아도 된다면, 이러한 관계설정을 제거 하는 것이 좋다.

SQL Server 에서 이것을 자동으로 병렬복제로 살려주는 경우는 없을듯 하다. 이것은 위 work-around 를 적용해 운영하던지 아니면, 위에서 예를 든 여러세션에서 구독 할 경우 에러가 일어날 수 있는 조건을 제거 할 수 있는지 알아보고 제거 하는 방법이 최선의 방법이 될 듯 하다. 

http://support.microsoft.com/kb/953199



Posted by 보미아빠
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함