블로그 이미지
LifeisSimple

calendar

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 31

Notice

2012. 5. 2. 22:01 Brain Trainning/DataBase


PAGEIOLATCH 리소스 조회 쿼리입니다.

Wait type을 변경하면 다른 리소스에 대한 것들도 조회가 가능합니다.

/*

           resource_description 컬럼

                     database_id:file_id:page_id 로구분되어짐.

*/

 

-- 현재PAGELATCH Wait를구함

select session_id, wait_type, resource_description

from sys.dm_os_waiting_tasks

where wait_type like 'PAGELATCH%'

 

-- PAGELATCHResource 상세정보를구함

select wt.session_id, wt.wait_type, wt.wait_duration_ms

, s.name as schema_name

, o.name as object_name

, i.name as index_name

from sys.dm_os_buffer_descriptors bd

join (

           select *

           , CHARINDEX(':', resource_description) as file_index

           , CHARINDEX(':', resource_description, charindex(':', resource_description)) as page_index

           , resource_description as rd

           from sys.dm_os_waiting_tasks wt

           where wait_type like 'PAGELATCH%'

           ) as wt

on bd.database_id = SUBSTRING(wt.rd, 0, wt.file_index) and bd.file_id = SUBSTRING(wt.rd, wt.file_index, wt.page_index)

and bd.page_id = SUBSTRING(wt.rd, wt.page_index, len(wt.rd))

join sys.allocation_units au on bd.allocation_unit_id = au.allocation_unit_id

join sys.partitions p on au.container_id = p.partition_id

join sys.indexes i on p.index_id = i.index_id and p.object_id = i.object_id

join sys.objects o on i.object_id = o.object_id

join sys.schemas s on o.schema_id = s.schema_id

posted by LifeisSimple
2012. 4. 26. 11:02 Brain Trainning/DataBase

데이터베이스별 버퍼 사용량을 측정할 수 있습니다. 


아래의 스크립트를 참조하시면 됩니다. 



SELECT [Database Name], sum([Page Count])

FROM (

SELECT

   (CASE WHEN ([is_modified] = 1) THEN 'Dirty' ELSE 'Clean' END) AS 'Page State',

   (CASE WHEN ([database_id] = 32767) THEN 'Resource Database' ELSE DB_NAME (database_id) END) AS 'Database Name',

   COUNT (*) AS 'Page Count'

FROM sys.dm_os_buffer_descriptors

WHERE database_id between 5 and 1000

GROUP BY [database_id], [is_modified]

) as K

GROUP BY [Database Name]

ORDER BY [Database Name]


아주 가끔씩 필요해지는 것들이 생기네요... 


흠... 

posted by LifeisSimple
2012. 4. 5. 19:19 Brain Trainning/DataBase

대기 상태에 대한 글입니다. 

간단히 읽어보면 도움이 많이 됩니다. 


출처 : http://www.sqlskills.com/BLOGS/PAUL/post/Wait-statistics-or-please-tell-me-where-it-hurts.aspx

(Be sure to join our community to get our monthly newsletter with exclusive content, advance notice of classes with discount codes, and other SQL Server goodies!)  

How many times have you walked up to a SQL Server that has a performance problem and wondered where to start looking? 

One of the most under-utilized performance troubleshooting methodologies in the SQL Server world is one called "waits and queues" (also known simply as "wait stats"). The basic premise is that SQL Server is permanently tracking why execution threads have to wait. You can ask SQL Server for this information and then use the results to narrow down where to start digging to unearth the cause of performance issues. The "waits" are what SQL Server tracks. The "queues" are the resources that the threads are waiting for. There are a myriad of waits in the system and they all indicate different resources being waited for. For example, a PAGEIOLATCH_EX wait means a thread is waiting for a data page to be read into the buffer pool from disk. A LCK_M_X wait means a thread is waiting to be granted an exclusive lock on something.

The great thing about all of this is the SQL Server *knows* where the performance issues are, and you just need to ask it.... and then interpret what it tells you, which can be a little tricky.

Now - where people sometimes get hung up is trying to track down every last wait and figure out what's causing it. Waits *always* occur. It's the way SQL Server's scheduling system works.

A thread is using the CPU (called RUNNING) until it needs to wait for a resource. It then moves to an unordered list of threads that areSUSPENDED. In the meantime, the next thread on the FIFO (first-in-first-out) queue of threads waiting for the CPU (called being RUNNABLE) is given the CPU and becomes RUNNING. If a thread on the SUSPENDED list is notified that it's resource is available, it becomes RUNNABLE and is put on the bottom of the RUNNABLE queue. Threads continue this clockwise movement from RUNNING to SUSPENDED to RUNNABLE to RUNNING again until the task is completed. You can see processes in these states using the sys.dm_exec_requests DMV. 

SQL Server keeps track of the time that elapses between leaving the RUNNING state and becoming RUNNING again (called the "wait time") and the time spent on the RUNNABLE queue (called the "signal wait time" - i.e. how long does the thread need to wait for the CPU after being signaled that its resource is available). We need to work out the time spent waiting on the SUSPENDED list (called the "resource wait time") by subtracting the signal wait time from the overall wait time.

Tom Davidson of Microsoft wrote a fantastic and very accessible whitepaper on "waits and queues" which I encourage you to read:Performance Tuning Using Waits and Queues. My good friend Joe Sack (blog|twitter) who runs the MCM program also published an excellent slide deck on the subject that you can download here. And of course Books Online has a section on the sys.dm_os_wait_stats DMVthat gives info on some of the newer wait types. PSS is putting together a repository of info on all the wait types but not much progress has been made. And there's a free video+demo recording as part of the MCM online training we recorded for Microsoft - see here.

You can ask SQL Server for the cumulative wait statistics using the sys.dm_os_wait_stats DMV, and many people prefer to wrap the DMV call in some aggregation code. I use code based on a query that I got from fellow-MVP Glenn Berry (blog|twitter) and then modified quite a bit. See below for the version updated to take account of the results discussed below:

WITH Waits AS
    (SELECT
        wait_type,
        wait_time_ms / 1000.0 AS WaitS,
        (wait_time_ms - signal_wait_time_ms) / 1000.0 AS ResourceS,
        signal_wait_time_ms / 1000.0 AS SignalS,
        waiting_tasks_count AS WaitCount,
        100.0 * wait_time_ms / SUM (wait_time_ms) OVER() AS Percentage,
        ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS RowNum
    FROM sys.dm_os_wait_stats
    WHERE wait_type NOT IN (
        'CLR_SEMAPHORE', 'LAZYWRITER_SLEEP', 'RESOURCE_QUEUE', 'SLEEP_TASK',
        'SLEEP_SYSTEMTASK', 'SQLTRACE_BUFFER_FLUSH', 'WAITFOR', 'LOGMGR_QUEUE',
        'CHECKPOINT_QUEUE', 'REQUEST_FOR_DEADLOCK_SEARCH', 'XE_TIMER_EVENT', 'BROKER_TO_FLUSH',
        'BROKER_TASK_STOP', 'CLR_MANUAL_EVENT', 'CLR_AUTO_EVENT', 'DISPATCHER_QUEUE_SEMAPHORE',
        'FT_IFTS_SCHEDULER_IDLE_WAIT', 'XE_DISPATCHER_WAIT', 'XE_DISPATCHER_JOIN', 'BROKER_EVENTHANDLER',
        'TRACEWRITE', 'FT_IFTSHC_MUTEX', 'SQLTRACE_INCREMENTAL_FLUSH_SLEEP',
        'BROKER_RECEIVE_WAITFOR', 'ONDEMAND_TASK_QUEUE', 'DBMIRROR_EVENTS_QUEUE',
        'DBMIRRORING_CMD', 'BROKER_TRANSMITTER', 'SQLTRACE_WAIT_ENTRIES',
        'SLEEP_BPOOL_FLUSH', 'SQLTRACE_LOCK')
    )
SELECT
    W1.wait_type AS WaitType, 
    CAST (W1.WaitS AS DECIMAL(14, 2)) AS Wait_S,
    CAST (W1.ResourceS AS DECIMAL(14, 2)) AS Resource_S,
    CAST (W1.SignalS AS DECIMAL(14, 2)) AS Signal_S,
    W1.WaitCount AS WaitCount,
    CAST (W1.Percentage AS DECIMAL(4, 2)) AS Percentage,
    CAST ((W1.WaitS / W1.WaitCount) AS DECIMAL (14, 4)) AS AvgWait_S,
    CAST ((W1.ResourceS / W1.WaitCount) AS DECIMAL (14, 4)) AS AvgRes_S,
    CAST ((W1.SignalS / W1.WaitCount) AS DECIMAL (14, 4)) AS AvgSig_S
FROM Waits AS W1
    INNER JOIN Waits AS W2 ON W2.RowNum <= W1.RowNum
GROUP BY W1.RowNum, W1.wait_type, W1.WaitS, W1.ResourceS, W1.SignalS, W1.WaitCount, W1.Percentage
HAVING SUM (W2.Percentage) - W1.Percentage < 95; -- percentage threshold
GO

This will show the waits grouped together as a percentage of all waits on the system, in decreasing order. The waits to be concerned about (potentially) are those at the top of the list as this represents the majority of where SQL Server is spending it's time waiting. You can see that a bunch of waits are being filtered out of consideration - as I said above, waits happen all the time and these are the benign ones we can usually ignore.

You can also reset the aggregated statistics using this code:

DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);

And of course you can very easily come up with a way to persist the results every few hours or every day and do some time-series analysis to figure out trends or automatically spot problems as they start to happen. You can also use Performance Dashboard to see these graphically in 2005 and Data Collector in 2008. On SQL Server 2000 you can use DBCC SQLPERF ('waitstats').

Once you get the results, you then start figuring out how to interpret them and where to go looking. The whitepaper I referenced above has a ton of good info on most of the wait types (except those added in 2008). There are various ways you can dig in deeper to this information that I'll go into in later posts.

I'm going to start blogging about wait stats analysis, either as standalone posts or as part of other things - and I've already done so in the last post (at time of writing this) in my benchmarking series.

For now, I want to report on the results of the wait stats survey I posted a couple of months back. I asked people to run the code above and let me know the results. I received results for a whopping 1823 SQL Servers out there - thank you!

Here's a graphical view of the results:

 

I'm not surprised at all by the top four results as I see these over and over on client systems.

For the remainder of this post, I'm going to list all the top wait types reported by survey respondents, in descending order, and give a few words about what they might mean if they are the most prevalent wait on your system. The list format shows the number of systems with that wait type as the most prevalent, and then the wait type.

  • 505: CXPACKET
    • This is commonly where a query is parallelized and the parallel threads are not given equal amounts of work to do, or one thread blocks. One thread may have a lot more to do than the others, and so the whole query is blocked while the long-running thread completes. If this is combined with a high number of PAGEIOLATCH_XX waits, it could be large parallel table scans going on because of incorrect non-clustered indexes, or out-of-date statistics causing a bad query plan. If neither of these are the issue, you might want to try setting MAXDOP to 4, 2, or 1 for the offending queries (or possibly the whole instance). Make sure that if you have a NUMA system that you try setting MAXDOP to the number of cores in a single NUMA node first to see if that helps the problem. You also need to consider the MAXDOP effect on a mixed-load system.
  • 304: PAGEIOLATCH_XX
    • This is where SQL Server is waiting for a data page to be read from disk into memory. It commonly indicates a bottleneck at the IO subsystem level, but could also indicate buffer pool pressure (i.e. not enough memory for the workload).
  • 275: ASYNC_NETWORK_IO
    • This is commonly where SQL Server is waiting for a client to finish consuming data. It could be that the client has asked for a very large amount of data or just that it's consuming it reeeeeally slowly because of poor programming.
  • 112: WRITELOG
    • This is the log management system waiting for a log flush to disk. It commonly indicates a problem with the IO subsystem where the log is, but on very high-volume systems it could also be caused by waiting for the LOGCACHE_ACCESS spinlock (which you can't do anything about). To be sure it's the IO subsystem, use the DMV sys.dm_io_virtual_file_stats to examine the IO latency for the log file.
  • 109: BROKER_RECEIVE_WAITFOR
    • This is just Service Broker waiting around for new messages to receive. I would add this to the list of waits to filter out and re-run the wait stats query. 
  • 086: MSQL_XP
    • This is SQL Server waiting for an extended stored-proc to finish. This could indicate a problem in your XP code. 
  • 074: OLEDB
    • As its name suggests, this is a wait for something communicating using OLEDB - e.g. a linked server. It could be that the linked server has a performance issue.
  • 054: BACKUPIO
    • This shows up when you're backing up directly to tape, which is slooooow. I'd be tempted to filter this out.
  • 041: LCK_M_XX
    • This is simply the thread waiting for a lock to be granted and indicates blocking problems. These could be caused by unwanted lock escalation or bad programming, but could also be from IOs taking a long time causing locks to be held for longer than usual. Look at the resource associated with the lock using the DMV sys.dm_os_waiting_tasks.
  • 032: ONDEMAND_TASK_QUEUE
    • This is normal and is part of the background task system (e.g. deferred drop, ghost cleanup).  I would add this to the list of waits to filter out and re-run the wait stats query.
  • 031: BACKUPBUFFER
    • This shows up when you're backing up directly to tape, which is slooooow. I'd be tempted to filter this out.
  • 027: IO_COMPLETION
    • This is SQL Server waiting for IOs to complete and is a sure indication of IO subsystem problems.
  • 024: SOS_SCHEDULER_YIELD
    • If this is a very high percentage of all waits (had to say, but Joe suggests 80%) then this is likely indicative of CPU pressure.
  • 022: DBMIRROR_EVENTS_QUEUE
  • 022: DBMIRRORING_CMD
    •  These two are database mirroring just sitting around waiting for something to do. I would add these to the list of waits to filter out and re-run the wait stats query.
  • 018: PAGELATCH_XX
    • This is contention for access to in-memory copies of pages. The most well-known cases of these are the PFS, SGAM, and GAM contention that can occur in tempdb under certain workloads. To find out what page the contention is on, you'll need to use the DMV sys.dm_os_waiting_tasks to figure out what page the latch is for. For tempdb issues, my friend Robert Davis (blog|twitter) has a good post showing how to do this. Another common cause I've seen is an index hot-spot with concurrent inserts into an index with an identity value key.
  • 016: LATCH_XX
    • This is contention for some non-page structure inside SQL Server - so not related to IO or data at all. These can be hard to figure out and you're going to be using the DMV sys.dm_os_latch_stats. More on this in future posts.
  • 013: PREEMPTIVE_OS_PIPEOPS
    • This is SQL Server switching to pre-emptive scheduling mode to call out to Windows for something. These were added for 2008 and haven't been documented yet (anywhere) so I don't know exactly what it means.
  • 013: THREADPOOL
    • This says that there aren't enough worker threads on the system to satisfy demand. You might consider raising the max worker threads setting.
  • 009: BROKER_TRANSMITTER
    • This is just Service Broker waiting around for new messages to send. I would add this to the list of waits to filter out and re-run the wait stats query. 
  • 006: SQLTRACE_WAIT_ENTRIES
    • Part of SQL Trace. I would add this to the list of waits to filter out and re-run the wait stats query.
  • 005: DBMIRROR_DBM_MUTEX
    •  This one is undocumented and is contention for the send buffer that database mirroring shares between all the mirroring sessions on a server. It could indicate that you've got too many mirroring sessions.
  • 005: RESOURCE_SEMAPHORE
    • This is queries waiting for execution memory (the memory used to process the query operators - like a sort). This could be memory pressure or a very high concurrent workload. 
  • 003: PREEMPTIVE_OS_AUTHENTICATIONOPS
  • 003: PREEMPTIVE_OS_GENERICOPS
    • These are SQL Server switching to pre-emptive scheduling mode to call out to Windows for something. These were added for 2008 and haven't been documented yet (anywhere) so I don't know exactly what it means.
  • 003: SLEEP_BPOOL_FLUSH
    • This is normal to see and indicates that checkpoint is throttling itself to avoid overloading the IO subsystem. I would add this to the list of waits to filter out and re-run the wait stats query.
  • 002: MSQL_DQ
    • This is SQL Server waiting for a distributed query to finish. This could indicate a problem with the distributed query, or it could just be normal.
  • 002: RESOURCE_SEMAPHORE_QUERY_COMPILE
    • When there are too many concurrent query compilations going on, SQL Server will throttle them. I don't remember the threshold, but this can indicate excessive recompilation, or maybe single-use plans.
  • 001: DAC_INIT
    • I've never seen this one before and BOL says it's because the dedicated admin connection is initializing. I can't see how this is the most common wait on someone's system... 
  • 001: MSSEARCH
    • This is normal to see for full-text operations.  If this is the highest wait, it could mean your system is spending most of its time doing full-text queries. You might want to consider adding this to the filter list. 
  • 001: PREEMPTIVE_OS_FILEOPS
  • 001: PREEMPTIVE_OS_LIBRARYOPS
  • 001: PREEMPTIVE_OS_LOOKUPACCOUNTSID
  • 001: PREEMPTIVE_OS_QUERYREGISTRY
    • These are SQL Server switching to pre-emptive scheduling mode to call out to Windows for something. These were added for 2008 and haven't been documented yet (anywhere) so I don't know exactly what it means. 
  • 001: SQLTRACE_LOCK
    • Part of SQL Trace. I would add this to the list of waits to filter out and re-run the wait stats query.

I hope you found this interesting! Let me know if there's anything in particular you're interested in seeing or just that you're following along and enjoying the ride!

posted by LifeisSimple
2012. 4. 4. 12:53 Brain Trainning/DataBase

대기 정보 분석을 위한 Best Reference 페이지들 입니다.

Performance_Tuning_Waits_Queues.doc


1. SQL Server Best Practices Article 

 - http://msdn.microsoft.com/en-us/library/cc966413.aspx

2. Performance Tuning With Wait Statistics 

 - http://blogs.msdn.com/joesack/archive/2009/04/22/presentation-deck-for-performance-tuning-with-wait-statistics.aspx

3. Wait statistics, or please tell me where it hurts

 - http://www.sqlskills.com/BLOGS/PAUL/post/Wait-statistics-or-please-tell-me-where-it-hurts.aspx

4. The SQL Server Wait Type Repository ..

 - http://blogs.msdn.com/b/passsql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx

5. Great Resource on SQL Server Wait Types

 - http://sqlserverperformance.wordpress.com/2009/12/21/great-resource-on-sql-server-wait-types

6. Tracking Session and Statement Level Waits

 - http://sqlblog.com/blogs/jonathankehayias/archive/2010/12/30/an-xevent-a-day-30-of-31-tracking-session-and-statement-levelwaits.aspx

7. Wait Stats Introductory References

 - http://blogs.msdn.com/b/jimmymay/archive/2009/04/26/wait-stats-introductory-references.aspx

8. Performance Blog

 - http://sqldoctor.idera.com/tag/wait-stats/



posted by LifeisSimple
2012. 4. 3. 22:48 Brain Trainning/DataBase


Database 파일들의 정보를 조회하는 스크립트 입니다. 

대충 대충 필요하겠다 싶은것을 정리했습니다. 

/*

           Database file 별상태점검

                     - by Koon

*/

create proc dbo.DBA_GetDBFilesInfo

as

 

set nocount on

 

if exists (select top 1 * from sys.tables where name = 'DBA_DBFileInfo')

           truncate table DBA_DBFileInfo

else

           create table DBA_DBFileInfo (db_name nvarchar(100), db_id int, file_id int, type_desc nvarchar(60), data_space_id int, name sysname, physical_name nvarchar(260),  state_desc nvarchar(60), size int, max_size int, growth int, is_percent_growth bit)

 

insert into  DBA_DBFileInfo (db_name , db_id, file_id, type_desc, data_space_id, name, physical_name,  state_desc, size, max_size, growth, is_percent_growth)

exec sp_msforeachdb 'use ?; select db_name(), db_id(), file_id, type_desc, data_space_id, name, physical_name,  state_desc, size, max_size, growth, is_percent_growth from sys.database_files'

 

select a.db_id, a.db_name, a.file_id, a.name, a.physical_name, state_desc, convert(varchar(20), (a.size * 8 / 1024)) + 'MB' as file_size, -- (BytesOnDisk / 1024 / 1024)  as used_size,

           max_size, (case when is_percent_growth = 1 then convert(varchar(3), a.growth) + '%' else convert(varchar(20), (a.growth * 8) / 1024) + 'MB' end) as file_growth,

           convert(decimal(13, 2), (NumberReads * 1.00 / (NumberReads + NumberWrites * 1.00)) * 100) as ReadsPercent,

           convert(decimal(13, 2), (NumberWrites * 1.00 / (NumberReads + NumberWrites * 1.00)) * 100) as WritesPercent,

           NumberReads, (BytesRead / 1024 / 1024) as MBytesRead, (IoStallReadMS / 1000) as IoStallReadSec,

           NumberWrites, (BytesWritten / 1024 / 1024) as MBytesWritten, (IoStallWriteMS / 1000) as IoStallWriteSec

from DBA_DBFileInfo a

           cross apply sys.fn_virtualfilestats(a.db_id, a.file_id)

order by a.db_id, a.file_id

posted by LifeisSimple
2012. 3. 27. 13:24 Brain Trainning/DataBase

현 DB 시스템의 대기상태를 정리해서 보여주는 쿼리입니다. 

어떤 대기로 인해 시스템 성능이 저하되었는지 확인하고 이에 따른 조치를 하고자할때 필요한 쿼리입니다. 


code by Glenn Berry

WITH Waits AS

    (SELECT

        wait_type,

        wait_time_ms / 1000.0 AS WaitS,

        (wait_time_ms - signal_wait_time_ms) / 1000.0 AS ResourceS,

        signal_wait_time_ms / 1000.0 AS SignalS,

        waiting_tasks_count AS WaitCount,

        100.0 * wait_time_ms / SUM (wait_time_ms) OVER() AS Percentage,

        ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS RowNum

    FROM sys.dm_os_wait_stats

    WHERE wait_type NOT IN (

        'CLR_SEMAPHORE', 'LAZYWRITER_SLEEP', 'RESOURCE_QUEUE', 'SLEEP_TASK',

        'SLEEP_SYSTEMTASK', 'SQLTRACE_BUFFER_FLUSH', 'WAITFOR', 'LOGMGR_QUEUE',

        'CHECKPOINT_QUEUE', 'REQUEST_FOR_DEADLOCK_SEARCH', 'XE_TIMER_EVENT', 'BROKER_TO_FLUSH',

        'BROKER_TASK_STOP', 'CLR_MANUAL_EVENT', 'CLR_AUTO_EVENT', 'DISPATCHER_QUEUE_SEMAPHORE',

        'FT_IFTS_SCHEDULER_IDLE_WAIT', 'XE_DISPATCHER_WAIT', 'XE_DISPATCHER_JOIN', 'BROKER_EVENTHANDLER',

        'TRACEWRITE', 'FT_IFTSHC_MUTEX', 'SQLTRACE_INCREMENTAL_FLUSH_SLEEP')

     )

SELECT

     W1.wait_type AS WaitType,

     CAST (W1.WaitS AS DECIMAL(14, 2)) AS Wait_S,

     CAST (W1.ResourceS AS DECIMAL(14, 2)) AS Resource_S,

     CAST (W1.SignalS AS DECIMAL(14, 2)) AS Signal_S,

     W1.WaitCount AS WaitCount,

     CAST (W1.Percentage AS DECIMAL(4, 2)) AS Percentage

FROM Waits AS W1

INNER JOIN Waits AS W2

     ON W2.RowNum <= W1.RowNum

GROUP BY W1.RowNum, W1.wait_type, W1.WaitS, W1.ResourceS, W1.SignalS, W1.WaitCount, W1.Percentage

HAVING SUM (W2.Percentage) - W1.Percentage < 95; -- percentage threshold

GO

posted by LifeisSimple
2012. 3. 21. 21:59 Photograph by ../일상
오늘 드뎌... 1편이 시작되는군요 ㅎㅎ

7광구를 말아드셨지만 여전히 기대가 되는 하지원의 "더킹 투하츠" 
이승기가 얼마나 잘 해줄지... 음... 그리고, 하지원은 되도록이면 그냥 표준어 썻으면 하는데... 

좀... 그렇네요... 아쉽지 않았으면 하는 바램이 ^^




방금 1편을 봤네요... 

생각보다 잘 어울리는 조합인것 같습니다. 하지원도 북한사투리가 나름 잘 어울리네요. 
앞으로 극 전개가 어떻게 될지 ... 초반 진행은 무척 빠르군요 ㅎㅎ
posted by LifeisSimple
2012. 3. 20. 23:17 Brain Trainning/DataBase

I/O 특성을 잘 고려해서 시스템을 운영해야 합니다.

특성은 크게 다음과 같이 특성을 구분할 수 있습니다.
1. OLTP 
 - Random IO가 많고 단순하며 Transaction 들이 짧은(?) 것이 특징입니다.
 - 디스크의 입장에서는 여기 저기 많은 곳을 돌아다니면서 데이터를 읽어와야 합니다.

2. OLAP/DSS  
 - Sequencial IO가 많고 Transaction 이 긴것(?) 이 특징입니다. 
 - 디스크의 입장에서는  Range에 대한 검색이 많아집니다.

위와 같은 구분 및 특징은 보편적인 것으로 대략적인 시스템의 구성에 대한 감을 잡을 수 있습니다. 

그러나, 좀더 디테일하게 들어가면 다음과 같은 것들에 대한 파악이 운영에 필요합니다.

I/O 의 측정

1. 운영중인 시스템
 - PhysicalDisk : Disk Reads/sec , PhysicalDisk : Disk Write/sec 카운터를 체크합니다.
 - 드라이브의 위의 카운터를 확인해 현재 디스크의 I/O 를 확인할 수 있습니다.
 - Physical Disk : Avg Disk Queue Length 를 확인해 보고 이 수가 2 이상일 경우 I/O 병목이 발생했다고 할 수 있습니다. 이때 참고해야할 것은 2라는 것은 스핀들 하나에 대한 값이라는 것입니다. 따라서 다수의 디스크를 사용하는 RAID에서는 2/(RAID에 포한된 디스크 수) 입니다. 
 - 만약 병목이 확인되면 Memory : Pages/sec 카운트를 확인해 봅니다. 이 카운트가 높으면 Memory 증설을 통해 I/O 부담을 줄일 수 있습니다.

 디스크 병목이면
 - 다른 물리적 드라이브로 파일 이 동
 - 더 빠른 디스크로 변경
 - RAID 에 디스크 추가
 등의 조치가 필요합니다. 

2. 신규시스템
 필요 디스크의 수
 Disk Transfers/sec (Disk Reads/sec + Disk Writes/sec)
 - Disk Transfers/sec 으로 IOPs를 추산 이를 통해서 필요한 Disk의 수를 계산해줍니다.
 - 공식 ) Required # Disks = (Reads/sec + (Writes/sec * RAID adjuster)) / Disk IOPS
    Raid adjuster : RAID 0 : 1, RAID 1, 10 : 2, RAID 5 : 4 로 추산합니다.

따라서, 디스크 하나의 IOPS를 125 로 계산하고, 2000 Transfers/sec (Read 1200, Write 800) 인 시스템은 RAID 10 으로 묶을 경우 디스크가 
- (1200 + 800 * 2 ) / 125 = 22.4 개의 디스크가 필요합니다. 
결론적으로 만일 산정한 DB Size 가 얼마 되지 않는다면... 돈질이 되겠네요.. 사용하지 않는 공간이 많아질 가능성이 있습니다. 
이때는 Fusion IO, SSD 등 고성능의 디스크 도입을 고려해볼만 합니다. 

 대역폭
 2000 * 8KB = 16MB 입니다.
 보통 FC의 대역폭을 6Gb로 보면 750MB 이므로 충분한 대역폭을 제공한다고 하겠습니다.

위와 같은 것들을 알고 이해하고 있어야 시스템의 I/O 병목을 예방 / 조치 할 수 있습니다. 
 
posted by LifeisSimple
2012. 3. 18. 09:54 Photograph by ../일상
옹달샘이 광고하는 옵티머스 뷰네요... 

옹달샘 드디어 메이저 CF를 득 했네요 ㅎㅎ 옵티머스 뷰도 기대합니다. ^^
 


posted by LifeisSimple
2012. 3. 14. 22:49 Brain Trainning/DataBase
아래의 DMV는 알아두면 삶(?)에 무척 도움이 되는 것들입니다.
대충 내용만 슬쩍봐도... 아... 이정도는 외우고 사용해야지 하는 생각이 드는... 만약 안든다면.. 당신은 DBA가 아닐수도 ㅎㅎ

아래 것들은 기본적으로 사용법과 내용을 알고 있어야 합니다.

1. sys.dm_os_sys_info
- 물리적 메모리 양 또는 CPU 개수, 버퍼 풀 내의 버퍼 개수 등과 같은 시스템의 전반적인 사항을 확인

2. sys.dm_exec_sessions
- 로그인, 호스트, 프로그램 정보, 상태, 환경, 세션사용 CPU, 메모리, I/O 요청 수 등을 보여줌

3. sys.dm_exec_requests
- 현재 활성화 되어 있는 모든 요청에 대한 정보를 보여줌 (블로킹 정보, 쿼리 실행환경 정보, CPU, 메모리, I/O 요청 수 등도 나타남

4. sys.dm_exec_connections
- 각 연결에 대한 상세정보 : 프로토콜, 인증방법, IP주소 등

5. sys.dm_exec_sql_text
- 데이터베이스 ID, 개체 ID, SQL 쿼리 텍스트 정보

6. sys.dm_exec_query_stats
- 캐시에 있는 모든 쿼리 실행 계획 출력. 물리/논리적 I/O 수 , 최소, 최대, 전체 소요 시간 등의 정보

7. sys.dm_exec_procedure_stats
- 모든 저장 프로시저에 대한 정보. 실행 횟수, I/O, 소요시간 등과 같은 실행정보도 포함

8. sys.dm_db_index_usage_stats
- 인덱스에 대한 사용 횟수와 사용자의 마지막 사용 시간. Seek, Scan, Lookup, Update 수 등을 나타냄

9. sys.dm_db_partition_stats
- 테이블의 크기와 행 수를 파악할때 사용

10. sys.dm_db_index_physical_stats
- 각 인덱스와 테이블의 파티션들에 대한 물리적인 정보를 제공. 인덱스와 할당 단위 유형, 조각화 수, 크기, 평균 조각화 비율, 페이지 수, 행 수 등의 정보를 보여줌.

11. sys.dm_sql_referenced_entities
- sysdepends 를 대체.
posted by LifeisSimple
prev 1 2 3 4 5 6 7 8 ··· 36 next