'분류 전체보기'에 해당되는 글 192건
- 2012.08.13 Resource Governor Category View
- 2012.08.13 실행 쿼리 memory 사용 대기 정보 1
- 2012.08.13 대랑 I/O 사용 세션 쿼리
- 2012.08.13 TEMPDB의 페이지 사용량 측정
- 2012.08.09 SSIS 데이터 이관 속도
- 2012.07.26 T-SQL:: 인덱스 압축 예상 Size
- 2012.02.09 SSIS::플랫 파일 가져오기 에러.
- 2012.01.30 복제::스키마 옵션
- 2012.01.30 VIM 명령어 정리
- 2012.01.29 TSQL::월별 누적 건수를 구하기.
- 2012.01.29 query plan의 실행 옵션 보기
- 2012.01.22 Dynamic Management Views
- 2011.12.06 모니터링::Index 생성 & Rebuild 진행 상황
- 2011.11.28 Resource Governor
- 2011.10.20 MongoDB 설치 - Windows 2
Resource Governor Category View
SQL Server 2008 이상.
-- 리소스 관리자 category view -- veiw any definition, 변경시 control server select * from sys.resource_governor_configuration with (nolock) SELECT classifier_function_id ,object_schema_name(classifier_function_id) AS 'Classifier UDF schema' ,object_name(classifier_function_id) AS 'Classifier UDF name' ,is_enabled FROM sys.resource_governor_configuration GO -- resource pool info select * from sys.resource_governor_resource_pools with (nolock) select * from sys.resource_governor_workload_groups with (nolock) -- 리소스 관리자를 변경했을 때 재구성 문 필요 여부 select * from sys.dm_resource_governor_configuration with (nolock) select * from sys.dm_resource_governor_workload_groups with (nolock) select * from sys.dm_resource_governor_resource_pools as with (nolock) select p.pool_id, g.group_id, p.name, p.statistics_start_time , p.total_cpu_usage_ms,p.used_memgrant_kb, p.active_memgrant_kb , p.min_cpu_percent, p.max_cpu_percent, p.min_memory_percent, p.max_memory_percent , g.name, g.importance,g.total_cpu_usage_ms, g.max_dop , g.total_query_optimization_count, g.active_parallel_thread_count from sys.dm_resource_governor_resource_pools as p with (nolock) join sys.dm_resource_governor_workload_groups as g with (nolock) on p.pool_id = g.pool_id order by p.pool_id
'Resource Governor' 카테고리의 다른 글
Resource Governor (0) | 2011.11.28 |
---|
실행 쿼리 memory 사용 대기 정보
SQL SERVER 2005 이상. - 일부 컬럼은 SQL 2008 이상
메모리 사용을 대기하는 쿼리의 정보를 반환합니다.
메모리 대기를 하지 않는 쿼리는 나타나지 않으며, 이 쿼리에 실행되는 내역이 많다면 메모리 할당 대기가 많다는 의미 입니다.
-- memory used select top 50 --mem.session_id,req.group_id, -- sql 2008 이상 가능 db_name(req.database_id) as db, mem.request_time, mem.grant_time, mem.granted_memory_kb,mem.used_memory_kb, mem.required_memory_kb, mem.query_cost,mem.timeout_sec,mem.wait_time_ms as 'wait_time', object_schema_name(sql_text.objectid,sql_text.dbid) as schema_n, object_name(sql_text.objectid, sql_text.dbid) as spname, CASE WHEN req.statement_end_offset = -1 and ( (req.statement_start_offset / 2) > DATALENGTH (sql_text.text) ) THEN convert(varchar(4000), substring(isnull(sql_text.text, '') , 1, ( ( DATALENGTH (sql_text.text) - 1 )/2 ) + 1 ) ) ELSE convert(varchar(4000), substring(isnull(sql_text.text, '') , (req.statement_start_offset / 2) + 1 , (( case when req.statement_end_offset = -1 then DATALENGTH (sql_text.text) else req.statement_end_offset end - req.statement_start_offset ) /2 ) + 1) ) END as query_text, ses.login_name, ses.host_name, ses.program_name, mem.scheduler_id from sys.dm_exec_requests as req with (nolock) join sys.dm_exec_sessions as ses with (nolock) on req.session_id = ses.session_id join sys.dm_exec_query_memory_grants as mem with (nolock) on req.request_id = mem.request_id and ses.session_id = mem.session_id cross apply sys.dm_exec_sql_text(req.sql_handle) as sql_text where ses.is_user_process = 1 and wait_type <> 'WAITFOR' --and req.database_id = db_id('tiger') -- and mem.grant_time is null -- not allocation order by used_memory_kb desc
'Monitoring' 카테고리의 다른 글
Tempdb 공간 사용 확인 (0) | 2013.09.13 |
---|---|
대랑 I/O 사용 세션 쿼리 (0) | 2012.08.13 |
TEMPDB의 페이지 사용량 측정 (0) | 2012.08.13 |
모니터링::Index 생성 & Rebuild 진행 상황 (0) | 2011.12.06 |
대랑 I/O 사용 세션 쿼리
SQL SERVER 2005 이상
1. I/O Pending 조회
-- ===================================== -- I/O pending -- 어떤 row도 반환되지 않아야 한다. -- ===================================== select database_id, db_name(database_id) as db_name, file_id, t2.io_type, io_stall, io_pending_ms_ticks, scheduler_address from sys.dm_io_virtual_file_stats(NULL, NULL)t1, sys.dm_io_pending_io_requests as t2 where t1.file_handle = t2.io_handle
2. 현재 db의 i/o stall 정보
-- ========================== -- 현재 db의 i/o _io_virtual_file -- ========================== declare @db_name sysname set @db_name = null select db_name(database_id), file_id ,io_stall_read_ms , cast((io_stall_read_ms+io_stall_write_ms)/(1.0+num_of_reads + num_of_writes) as numeric(10,1)) as 'avg_io_stall_ms' , num_of_reads , cast(io_stall_read_ms/(1.0+num_of_reads) as numeric(10,1)) as 'avg_read_stall_ms' , io_stall_write_ms ,num_of_writes , cast(io_stall_write_ms/(1.0+num_of_writes) as numeric(10,1)) as 'avg_write_stall_ms' , io_stall_read_ms + io_stall_write_ms as io_stalls , num_of_reads + num_of_writes as total_io from sys.dm_io_virtual_file_stats(DB_ID(@db_name),null) order by avg_io_stall_ms desc
3. 대량의 i/o 사용 쿼리
-- ========================== -- 대량의 i/o기준 상위 -- ========================== SELECT TOP 10 qt.dbid, object_schema_name(qt.objectid,qt.dbid) + '.' + object_name(qt.objectid,qt.dbid) [object_name], (qs.total_logical_reads/execution_count) as avg_logical_reads, (qs.total_logical_writes/execution_count) as avg_logical_writes, (qs.total_logical_reads + qs.total_logical_writes) / qs.execution_count as [Avg IO], substring (qt.text,qs.statement_start_offset/2, (case when qs.statement_end_offset = -1 then len(convert(nvarchar(max), qt.text)) * 2 else qs.statement_end_offset end - qs.statement_start_offset)/2) as query_text, qt.objectid, object_name(qt.objectid) as sp_name FROM sys.dm_exec_query_stats qs cross apply sys.dm_exec_sql_text (qs.sql_handle) as qt ORDER BY [Avg IO] DESC
'Monitoring' 카테고리의 다른 글
Tempdb 공간 사용 확인 (0) | 2013.09.13 |
---|---|
실행 쿼리 memory 사용 대기 정보 (1) | 2012.08.13 |
TEMPDB의 페이지 사용량 측정 (0) | 2012.08.13 |
모니터링::Index 생성 & Rebuild 진행 상황 (0) | 2011.12.06 |
TEMPDB의 페이지 사용량 측정
SQL SERVER 2005 이상
실행 되는 SESSION TEMPDB의 페이지 사용량 측정.
세가지 쿼리다 결과는 같음.
--각 세션별 사용되는 Page, Plan, Statement WITH BASE AS ( SELECT session_id, request_id, SUM(internal_objects_alloc_page_count) AS [internal object pages alloc used], (SUM(internal_objects_alloc_page_count)*1.0/128) AS [internal object alloc space in MB], SUM(internal_objects_dealloc_page_count) AS [internal object pages dealloc used], (SUM(internal_objects_dealloc_page_count)*1.0/128) AS [internal object dealloc space in MB], SUM(user_objects_alloc_page_count) AS [user object pages alloc used], (SUM(user_objects_alloc_page_count)*1.0/128) AS [user object alloc space in MB], SUM(user_objects_dealloc_page_count) AS [user object pages dealloc used], (SUM(user_objects_dealloc_page_count)*1.0/128) AS [user object dealloc space in MB] FROM sys.dm_db_task_space_usage GROUP BY session_id, request_id ) SELECT object_schema_name(R3.objectid,R3.dbid) + '.' + object_name(R3.objectid,R3.dbid) as [object_name], R1.session_id, R1.request_id, R1.[internal object pages alloc used], R1.[internal object alloc space in MB], R1.[internal object pages dealloc used], R1.[internal object dealloc space in MB], R1.[user object pages alloc used], R1.[user object alloc space in MB], R1.[user object pages dealloc used], R1.[user object dealloc space in MB], R2.statement_start_offset, R2.statement_end_offset, R4.QUERY_PLAN, R3.text FROM BASE R1 INNER JOIN sys.dm_exec_requests R2 ON R1.session_id = R2.session_id and R1.request_id = R2.request_id OUTER APPLY sys.dm_exec_sql_text(R2.sql_handle) AS R3 OUTER APPLY sys.dm_exec_query_plan(R2.plan_handle) AS R4 WHERE R1.session_id > 50 ORDER BY 4 desc
select top 50 u.session_id, s.host_name, s.login_name, s.status, s.program_name, sum(u.user_objects_alloc_page_count+u.internal_objects_alloc_page_count)*8 tempdb_space_alloc_kB, sum(u.user_objects_dealloc_page_count+u.internal_objects_dealloc_page_count)*8 tempdb_space_dealloc_kB, sum(u.user_objects_alloc_page_count+u.internal_objects_alloc_page_count -u.user_objects_dealloc_page_count - u.internal_objects_dealloc_page_count)*8 remaining_tempdb_space_alloc_kB from sys.dm_db_session_space_usage as u join sys.dm_exec_sessions as s on s.session_id = u.session_id where u.database_id = 2 group by u.session_id, s.host_name, s.status, s.login_name, s.program_name order by 7 desc
SELECT task.session_id, ses.host_name, ses.login_name ,ses.login_time, task.request_id, task.alloc,task.dealloc ,object_name(qt.objectid, qt.dbid) as 'SPname' ,req.cpu_time,req.logical_reads,req.reads, req.writes ,substring(qt.text,req.statement_start_offset/2, (case when req.statement_end_offset = -1 then len(convert(nvarchar(max), qt.text)) * 2 else req.statement_end_offset end - req.statement_start_offset)/2) as query ,req.statement_start_offset, req.statement_end_offset, req.plan_handle, req.sql_handle FROM ( Select session_id, request_id, SUM(internal_objects_alloc_page_count) /128 as alloc, SUM (internal_objects_dealloc_page_count)/128 as dealloc FROM sys.dm_db_task_space_usage with (nolock) GROUP BY session_id, request_id ) AS task inner join sys.dm_exec_requests AS req with (nolock) on task.session_id = req.session_id and task.request_id = req.request_id inner join sys.dm_exec_sessions as ses with(nolock) on req.session_id = ses.session_id CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS qt ORDER BY task.alloc DESC
'Monitoring' 카테고리의 다른 글
실행 쿼리 memory 사용 대기 정보 (1) | 2012.08.13 |
---|---|
대랑 I/O 사용 세션 쿼리 (0) | 2012.08.13 |
모니터링::Index 생성 & Rebuild 진행 상황 (0) | 2011.12.06 |
T-SQL:: Default Trace로 DB 증가량 확인 (1) | 2011.04.15 |
SSIS 데이터 이관 속도
- ODBC Tasks : 5 minutes 57 seconds
- ADO NET Tasks : 11 seconds
- OLEDB Task
- fast load, table lock option: 5 seconds.
- table or view option : 2 minutes and 21 seconds
- sql command : 2.85 seconds.
- SQL Server Destination
- oledb destination : 2.5 seconds.
- T-SQL Tasks
- 프로시저 생성해서 작업 : 1.8 seconds! -> 이건 같은 DB 일 때 네요.
'Business Inteligence (SSIS)' 카테고리의 다른 글
SSIS::플랫 파일 가져오기 에러. (0) | 2012.02.09 |
---|---|
SQL2008에서 SQL2000 DTS열기 (0) | 2010.06.07 |
For컨테이너-무한루프 (0) | 2010.06.03 |
스크립트task사용 (0) | 2010.06.03 |
T-SQL:: 인덱스 압축 예상 Size
인덱스 압축 했을 때 예상 사이즈 조회
exec sp_estimate_data_compression_savings @schema_name = 'dbo' ,@object_name = '테이블명' ,@index_id = 1 ,@partition_number = null, @data_compression = 'page' -- 압축 방법
'T-SQL' 카테고리의 다른 글
T-SQL::동적 PIVOT 생성 (3) | 2012.11.02 |
---|---|
Function to return a range of dats - 날짜 범위 펑션 (0) | 2012.11.01 |
TSQL::월별 누적 건수를 구하기. (0) | 2012.01.29 |
T-SQL::테이블 확장속성 (0) | 2011.10.05 |
SSIS::플랫 파일 가져오기 에러.
ssis 버그라고 하는데 SQL R2 버전이면서 win7 x64일 경우 발생한다.
아래는 버그에 대한 설명이고 sp2를 설치하면 된다고 한다.
혹은 플랫 파일 연결자의 속성중 TextQualifier 를 아무것도 없이 지운다.
http://support.microsoft.com/kb/2576118
'Business Inteligence (SSIS)' 카테고리의 다른 글
SSIS 데이터 이관 속도 (0) | 2012.08.09 |
---|---|
SQL2008에서 SQL2000 DTS열기 (0) | 2010.06.07 |
For컨테이너-무한루프 (0) | 2010.06.03 |
스크립트task사용 (0) | 2010.06.03 |
복제::스키마 옵션
Problem
My company uses replication quite extensively across SQL 2000, SQL 2005 and SQL 2008 servers. The problem with using different versions of SQL Server is that the replication options do not always behave the same way. Because of these differences we have stopped using SQL Server Management Studio and Enterprise Manager to setup replication. Also we have taken the time to look at the schema options for replication to make sure the end result is the same for all versions of SQL Server.
Solution
We basically have two requirements for replication which are outlined below. I have listed the different schema options that the GUI generates to show how things work differently in different versions of SQL Server as well as the options we selected for our environment.
Background Information
Here are two articles related to this tip that you should understand.
- Books Online: sp_addarticle (Transact-SQL)
- How to: Specify Schema Options (Replication Transact-SQL Programming)
If you look at the schema option on sp_addarticle (Transact-SQL), you will see there are over 40 combinations of schema options and it can be hard to know which one to choose. The article, How to: Specify Schema Options (Replication Transact-SQL Programming) shows how to figure out and specify schema options.
Replication Requirements
My company has two different requirements for replication as outlined below. When using the GUI with different versions of SQL Server several different schema options are generated, but they do not always work the same across all versions of SQL Server.
Requirement 1
- Replicate the Primary Key with index that is related to the primary key constraint
- Convert User Defined Types (UDTs) to base data types at the Subscriber
- Use SQL Stored Procedures to replicate (auto generate store procedures on subscribers for Insert, Update and Delete)
Based on the above, I have tested the below combinations and as you can see different version have different results for the 0xB3 option.
Schema Option |
Publisher Version |
Distributor Version |
Subscriber Version |
Description |
0x00000000000000A3 | SQL2K | SQL2K5 | SQL2K | No PK with same index type as PK |
SQL2K | SQL2K5 | SQL2K8 | No PK with same index type as PK | |
SQL2K8 | SQL2K8 | SQL2K8 | No PK with same index type as PK | |
0x00000000000080A3 | SQL2K | SQL2K5 | SQL2K | PK with no other index |
SQL2K | SQL2K5 | SQL2K8 | PK with no other index | |
SQL2K8 | SQL2K8 | SQL2K8 | PK with no other index | |
0x00000000000000B3 | SQL2K | SQL2K5 | SQL2K | The same index as PK on publisher, but NO PK constraints |
SQL2K | SQL2K5 | SQL2K8 | The same index as PK on publisher, but NO PK constraints |
|
SQL2K | SQL2K8 | SQL2K8 | The same index as PK on publisher, but NO PK constraints |
|
SQL2K5 | SQL2K8 | SQL2K8 | PK with no other index with clustered index | |
SQL2K8 | SQL2K8 | SQL2K8 | PK with no other index with clustered index | |
0x00000000000080B3 | SQL2K | SQL2K5 | SQL2K | PK with clustered index even if the index is not part of PK |
SQL2K | SQL2K5 | SQL2K8 | PK with clustered index even if the index is not part of PK |
|
SQL2K8 | SQL2K8 | SQL2K8 | PK with clustered index even if the index is not part of PK |
|
0x00000000000082A3 | SQL2K | SQL2K5 | SQL2K | PK + FK with clustered index even if the index is not part of PK |
SQL2K | SQL2K5 | SQL2k8 | PK + FK with clustered index even if the index is not part of PK |
|
SQL2K8 | SQL2K8 | SQL2K8 | PK + FK with clustered index even if the index is not part of PK |
* PK - Primary Key
* FK - Foreign Key
So, based on the above, I have concluded that our company, "0x00000000000080A3" fits our needs.
Requirement 2
- All of the Requirement 1 plus
- Replicate all Indexes on Publisher
Schema Option | Publisher Version |
Distributor Version |
Subscriber Version |
Description |
0x0000000000001073 | SQL2K | SQL2K5 | SQL2k | No PK with all indexes (no FK) |
SQL2K | SQL2K5 | SQL2k8 | No PK with all indexes (no FK) | |
SQL2K8 | SQL2K8 | SQL2K8 | PK with all indexes (no FK) | |
0x00000000000080F3 | SQL2K | SQL2K5 | SQL2k | PK with all indexes (no FK) |
SQL2K | SQL2K5 | SQL2k8 | PK with all indexes (no FK) | |
SQL2K8 | SQL2K8 | SQL2K8 | PK with all indexes (no FK) | |
0x00000000000082F3 | SQL2K | SQL2K5 | SQL2k | PK+FK with all indexes |
SQL2K | SQL2K5 | SQL2k8 | PK+FK with all indexes | |
SQL2K8 | SQL2K8 | SQL2K8 | PK+FK with all indexes |
Based on the testing, we have decide to use "0x00000000000080F3".
Confirmation
Now, here is simple query that I use to confirm the options.
If you run this for 0x00000000000080A3:
declare @pubid int declare @optionid bigint declare @schema_option varbinary(2000) set @optionid = 1 set @schema_option = 0x00000000000080A3 WHILE (@optionid <= 2147483648) BEGIN if (select @schema_option & @optionid) > 0 PRINT cast(@optionid as varbinary) SET @optionid = @optionid * 2 END |
You will see this result:
0x0000000000000001 0x0000000000000002 0x0000000000000020 0x0000000000000080 0x0000000000008000 |
You can check Books Online: sp_addarticle (Transact-SQL) and you will see the below options. Note, in Books Online they shorten the notation, so 0x0000000000000001 = 0x01.
- 0x0000000000000001 - Generates the object creation script (CREATE TABLE, CREATE PROCEDURE, and so on). This value is the default for stored procedure articles.
- 0x0000000000000002 - Generates the stored procedures that propagate changes for the article, if defined.
- 0x0000000000000020 - Converts user-defined data types (UDT) to base data types at the Subscriber. This option cannot be used when there is a CHECK or DEFAULT constraint on a UDT column, if a UDT column is part of the primary key, or if a computed column references a UDT column. Not supported for Oracle Publishers.
- 0x0000000000000080 - Replicates primary key constraints. Any indexes related to the constraint are also replicated, even if options 0x10 and 0x40 are not enable
- 0x0000000000008000 - This option is not valid for SQL Server 2005 Publishers.
If we do the same for 0x00000000000080F3, we get this output:
- 0x0000000000000001 - Generates the object creation script (CREATE TABLE, CREATE PROCEDURE, and so on). This value is the default for stored procedure articles.
- 0x0000000000000002 - Generates the stored procedures that propagate changes for the article, if defined.
- 0x0000000000000010 - Generates a corresponding clustered index. Even if this option is not set, indexes related to primary keys and unique constraints are generated if they are already defined on a published table.
- 0x0000000000000020 - Converts user-defined data types (UDT) to base data types at the Subscriber. This option cannot be used when there is a CHECK or DEFAULT constraint on a UDT column, if a UDT column is part of the primary key, or if a computed column references a UDT column. Not supported for Oracle Publishers.
- 0x0000000000000040 - Generates corresponding nonclustered indexes. Even if this option is not set, indexes related to primary keys and unique constraints are generated if they are already defined on a published table.
- 0x0000000000000080 - Replicates primary key constraints. Any indexes related to the constraint are also replicated, even if options 0x10 and 0x40 are not enable
- 0x0000000000008000 - This option is not valid for SQL Server 2005 Publishers.
'Replication' 카테고리의 다른 글
SQL Server Replication Error - The specified LSN for repldone log scan occurs before the current start of replication in the log (0) | 2014.08.19 |
---|---|
복제::숨겨진 저장프로시저 확인 (0) | 2011.01.16 |
복제::LOB DataType 제한 (0) | 2010.06.04 |
복제::#5 구현&삭제 스크립트 (0) | 2010.06.04 |
VIM 명령어 정리
VIM 명령어 정리
1. 저장 및 종료
명령어 |
설명 |
:w |
저장 |
:w file.txt |
file.txt 파일로 저장 |
:w » file.txt |
file.tx파일에 덧붙여서 저장 |
:q |
vi 종료 |
:q! |
vi 강제 종료 |
ZZ |
저장 후 종료 |
:wq! |
강제 저장 후 종료 |
:e file.txt |
file.txt파일을 불러옴 |
:e |
현재 파일을 불러옴 |
:e# |
바로 이전에 열었던 파일을 불러 옴 |
2. 입력모드 전환
a |
커서 위치 다음칸부터 입력 |
A |
커서 행의 맨 마지막부터 입력 |
i |
커서의 위치에 입력 |
I |
커서 행의 맨 앞에서 부터 입력 |
o |
커서의 다음행에 입력 |
O |
커서의 이전 행에 입력 |
s |
커서 위치의 한글자를 지우고 입력 |
cc |
커서위치의 한 행을 지우고 입력 |
3. 이동
h |
왼쪽으로 이동 |
l |
오른쪽으로 이동 |
j |
아래행으로 이동 |
k |
위 행으로 이동 |
w 또는 W |
다음 단어의 첫 글자로 이동 |
b 또는 B |
이전 단어의 첫 글자로 이동 |
e 또는 E |
단어의 마지막 글자로 이동 |
<CR> |
다음행 첫 첫 글자로 이동 |
^ |
그행의 첫 글자로 이동 |
$ |
그 행의 마지막 글자로 이동 |
+ |
다음 행의 첫 글자로 이동 |
- |
위 행의 첫 글자로 이동 |
( |
이전 문장의 첫 글자로 이동 |
) |
다음 문장의 첫 글자로 이동 |
{ |
이전 문단으로 이동 |
} |
다음 문단으로 이동 |
H |
커서를 화면 맨 위로 이동 |
z<CR> |
현재 행을 화면의 맨우로 이동 |
M |
커서를 화면 중안으로 이동 |
z. |
현재 행을 화면의 중앙으로 이동 |
L |
커서를 화면 최하단으로 이동 |
z- |
현재 행의 화면의 최하단으로 이동 |
[n]H |
커서를 위에서 n행으로 이동 |
[n]L |
커서를 아래에서 n행으로 이동 |
ctrl+u |
반 화면 위로 스크롤 |
ctrl+d |
반 화면 아래로 스크롤 |
ctrl+b |
한 화면 위로 스크롤 |
ctrl+f |
한 화면 아래 스크롤 |
gg 또는 1G |
문서의 맨 처음으로 이동 |
G |
문서의 맨 마지막 행으로 이동 |
[n]G 또는 :[n] |
n행으로 이동 |
4. 삭제
x 또는 dl |
커서 위치의 글자 삭제 |
X 또는 dh |
커서 바로 앞의 글자 삭제 |
dw |
현재 위치부터 스페이스 까지 삭제 |
diw |
현재 위치에 있는 단어 삭제 |
dd |
커서가 있는 행을 삭제 |
[n]dd |
현재 커서 부터 아래 n번째 줄까지 삭제 |
dj |
현재 커서와 아래 줄 삭제 |
[n]dj |
현재 커서 부터 아래 n+1번째 줄까지 삭제 |
dk |
현재 커서와 윗로 n+1번째 줄까지 삭제 |
[n]dk |
현재 커서와 윗 줄 삭제 |
D 또는 d$ |
현재 커서가 있는 위치부터 행 끝까지 삭제 |
d0 또는 d^ |
현재 커서가 있는 위치부터 행 시작 까지 삭제 |
5. 복사 & 붙여넣기
yy 또는 Y |
커서가 있는 한 행 복사 |
p |
현재 커서에 붙여 넣기, 행 복사 일 경우 아래 줄에 붙여넣음. |
P |
현재 커서위치의 앞행에 붙여 넣기, 행 복사일 경우에는 윗 줄에 붙여 넣음 |
[n]yy 또는 [n]Y |
커서가 위치한 이후로 n행 복사 |
[n]p |
n번 만큼 붙여넣기 반복 |
6. 블록 지정
v |
블록 지정 |
V |
줄단위 블록 지정 |
ctrl+v(윈도우에서는 ctrl+q) |
비쥬얼 블록 지정 |
블록 지정 중 명령 |
|
y |
블록 복사 하기 |
r |
치환 |
d |
지정 블록 지우기 |
U |
대문자로 바꾸기 |
u |
소문자로 바꾸기 |
~ |
대소문자 전환 |
J |
행 합침 |
: |
선택 영역에 대하여 ex명령 |
< |
행 앞에 탭 제거 |
> |
행 앞에 탭 삽입 |
7. 문자열 탐색 및 치환
/[문자열] |
문자열 탐색 |
:s/old/new |
현재 행의 처음 old를 new로 교체 |
:s/old/new/g |
현재 행의 모든 old를 new로 교체 |
:10,20s/old/new/g |
10행부터 20행까지 모든 old를 new로 교체 |
[블록지정중]:s/old/new/g |
지정 블록 내에서 모든 old를 new로 교체 |
:-3,+4s/old/new/g |
현재 커서 위치에서 위로 3행 아래로 4행까지의 old를 new로 교체 |
:%s/old/new/g |
문서 전체에서 old를 new로 교체 |
:%s/old/new/gc |
문서 전체에서 old를 new로 확인하며 교체 |
:g/pattern/s/old/new/g |
pattern이 있는 모든 행의 old를 new로 교체 |
8. vim 정규 표현식
^ |
행의 첫 문자([]안에서는 not의 의미) |
$ |
행의 끝 |
. |
아무 문자나 한 문자 의미 |
\| |
or의 의미 |
[ ] |
[]사이의 문자 중 하나 |
\{min,max\} |
min이상 max이하 반복됨 |
* |
앞의 내용이 0번 이상 반복됨 |
\+ |
앞의 내용이 1번 이상 반복됨 |
\< |
단어의 시작 |
\> |
단어의 끝 |
\n |
새 행 문자 |
\t |
탭 문자 |
9. vim 확장 정규 표현 문자열
\i |
변수 지정에 사용되는 문자들 [0-9A-Za-z] |
\I |
\i와 같지만 숫자는 제외 |
\k |
keyword로 사용하는 문자 [_\.\-0-9A0Za-z] |
\f |
파일 이름으로 사용하는 문자 |
\p |
프린트 가능한 문자 |
\P |
\p와 같지만 숫자는 제외 |
\s |
whitespace character(공백과 탭) |
\S |
non-whitespace character |
\d |
숫자 [0-9] |
\D |
숫자가 아닌 문자 [^0-9] |
\x |
16진수 숫자 [0-9A-Fa-f] |
\X |
16진수 숫자가 아닌 문자 [^0-9A-Fa-f] |
\o |
8진수 숫자 [0-7] |
\O |
8진수 숫자가 아닌 문자 [^0-7] |
\w |
영문 단어의 시작에 사용되는 문자 [0-9A-Za-z-] |
\W |
영문 단어에서 사용되지 않는 문자 [^0-9A-Za-z-] |
\h |
영문 단어의 시작에 사용되는 문자 [A-Za-z-] |
\H |
영문 단어의 시작에 사용 되지 않는 문자 [^A-Za-z-] |
\a |
모든 알파벳 [A-Za-z] |
\A |
알파벳이 아닌 문자 [^A-Za-z] |
\l |
소문자 [a-z] |
\L |
소문자가 아닌 문자 [a-z] |
\u |
대문자 [A-Z] |
\U |
대문자가 아닌 문자 [^A-Z] |
\e |
Esc |
\t |
Tab |
\r |
캐리지 리턴 |
\b |
백스페이스 |
\n |
새 행 |
10. POSIX 문자 클래스
문자 클래스 |
내용 |
[:alnum:] |
알파벳과 숫자 [A-Za-z0-9] |
[:alpha:] |
알파벳 [A-Za-z] |
[:cntrl:] |
제어 문자 |
[:blank:] |
탭과 공백 문자 |
[:digit:] |
숫자 [0-9] |
[:graph:] |
제어문자와 공백 무자를 제외한 문자 |
[:lower:] |
소문자 [a-z] |
[:upper:] |
대문자 [A-Z] |
[:print:] |
제어문자를 제외한 문자, 즉 프린터 할 수 있는 문자 |
[:punct:] |
[:graph:]문자 중 [:alnum:]을 제외한 문자. ex)!,@,#,$,%,^.... |
[:space:] |
화이트스페이스 ex)공백, 탭, 케리지 리턴, 새행, 수직탭, 폼필드 |
[:xdigit:] |
16진수 |
11. 파일 버퍼
:files 또는 :ls 또는 :buffers |
버퍼 목록 나열 |
:b[n] |
n번 버퍼로 이동 |
:bd[n] 또는 :bw[n] |
n번 버퍼를 삭제 (n이 없으면 현재의 버퍼를 삭제) |
:bp[n] |
이전 버퍼로 이동,n을 붙이면 n번만큼 이전 버퍼로 이동 |
:bn[n] |
이후 버퍼로 이동,n을 붙이면 n번만큼 이후 버퍼로 이동 |
:sb[n] |
창을 수평분할 하여 n번 버퍼를 로드 |
:bf |
첫 번째 버퍼로 이동 |
:bl |
마지막 버퍼로 이동 |
:tabnew |
새로운 탭을 열기 |
:tabnew b.txt |
b.txt가 존재하면 열고, 없으면 새로 만들어서 연다 |
:tabf b.txt |
b.txt가 존재하면 열고, 없으면 에러 발생 |
:tabn[n] |
다음 탭을 열기,n을 붙이면 n번 만큼 이동 |
:tabp[n] |
이전 탭을 열기,n을 붙이면 n번 만큼 이동 |
:tabs |
탭 목록 보기 |
:tabclose |
탭을 닫기 |
:tabfirst |
첫번째 탭을 열기 |
:tablast |
마지만 탭을 열기 |
:tabdo %s/old/new/g |
모든 탭에 적용을 원할 때 (예 모든탭에서 old를 new로 변경) |
13. 다중 창 관련 명령
명령모드 |
ex모드 |
결과 |
창생성 |
||
CTRL-W s |
:[N]sp[plit] |
현재 파일을 두 개의 수평 창으로 나눔 |
CTRL-W v |
:[N]vs[plit] |
현재 파일을 두 개의 수직 창으로 나눔 |
CTRL-W n |
:new |
새로운 수평 창 생성 |
CTRL-W ^ 또는 CTRL-W CTRL-^ |
수평 창으로 나누고 이전 파일의 오픈 |
|
CTRL-W f |
창을 수평으로 나누고 커서 위치의 파일 오픈 |
|
CTRL-W i |
커서 위치의 단어가 정의된 파일을 오픈 |
|
창삭제 |
||
CTRL-W q |
:q[uit]! |
현재 커서의 창을 종료 |
CTRL-W c |
:close |
현재 커서의 창 닫기 |
CTRL-W o |
:on[ly] |
현재 커서의 창만 남기고 모든 창 삭제 |
창이동 |
||
CTRL-W h |
왼쪽 창으로 커서 이동 |
|
CTRL-W j |
아래쪽 창으로 커서 이동 |
|
CTRL-W k |
위쪽 창으로 커서 이동 |
|
CTRL-W l |
오른쪽 창으로 커서 이동 |
|
CTRL-W w |
창을 순차적으로 이동 |
|
CTRL-W p |
가장 최근에 이동한 방향으로 이동 |
|
CTRL-W t |
최상위 창으로 이동 |
|
CTRL-W b |
최하위 창으로 이동 |
|
창이동 |
||
CTRL-W r |
순착으로 창의 위치를 순환 |
|
CTRL-W x |
이전 창과 위치를 바꿈 |
|
CTRL-W H |
||
CTRL-W J |
||
CTRL-W K |
||
CTRL-W L |
||
창 크기 조정 |
||
CTRL-W = |
창의 크기를 모두 균등하게 함 |
|
CTRL-W _ |
수평 분할에서 창의 크기를 최대화 |
|
CTRL-W | |
수직 분할에서 창의 크기를 최대화 |
|
CTRL-W [N]+ |
:res[ize] +N |
창의 크기를 N행 만큼 증가 |
CTRL-W [N]- |
:res[ize] -N |
창의 크기를 N행 만큼 감소 |
CTRL-W [N]> |
창의 크기를 오른쪽으로 N칸 만큼 증가 |
|
CTRL-W [N]< |
창의 크기를 오른쪽으로 N칸 만큼 감소 |
예) CTRL-W j 는 CTRL-W CTRL-J와 같다.
14. 마킹 및 마킹위치로 이동
m[a-z0-9] |
파일내에서 마킹, 현재 버퍼내에서만 이동 함 예)ma |
m[A-Z] |
전체영역에서 마킹, 다른 파일로도 이동 함. |
`[A-Za-z0-9] |
마킹된 위치로 돌아감 예)`a |
’[A-Za-z0-9] |
마킹된 행의 처으으로 이동함. 예)‘a |
” |
직전에 커서가 위치하던 행의 처음 |
`` |
직전의 커서 위치로 이동 |
’” |
이전에 vim으로 현재 파일을 닫았을 때 커서가 있던 행의 처음으로 이동 |
`" |
이전에 vim으로 현재 파일을 닫았을 때 커서가 있던 위치로 이동 |
TSQL::월별 누적 건수를 구하기.
- 고객수 월별 누적 건수를 구하거나 할때 이용할 수 있음.
'T-SQL' 카테고리의 다른 글
Function to return a range of dats - 날짜 범위 펑션 (0) | 2012.11.01 |
---|---|
T-SQL:: 인덱스 압축 예상 Size (0) | 2012.07.26 |
T-SQL::테이블 확장속성 (0) | 2011.10.05 |
T-SQL::create assembly (0) | 2011.10.03 |
query plan의 실행 옵션 보기
- sql server에 실행되고 있는 query 들의 실제 plan 하고 다르게 테스트 한 plan이 다르게 나타나는 경우가 있다.
- 실제 서버에서 실행되는 옵티마이저가 판단하는 세션에 대한 옵션이 다를 수 있기 때문이다.
- 실행되는 plan_handle 값에 대한 속성 값을 아래 쿼리에서 확인 할 수 있다.
SELECT DEQP.query_plan, DEPA.attribute, DEPA.value FROM sys.dm_exec_cached_plans DECP CROSS APPLY sys.dm_exec_query_plan(DECP.plan_handle) AS DEQP CROSS APPLY sys.dm_exec_plan_attributes(DECP.plan_handle) AS DEPA WHERE DECP.plan_handle = (0x0600010069AB592540617182000000000000000000000000) -- 특정 login 에 대한 옵션 SELECT SDEQP.query_plan, SDEPA.attribute, SDEPA.value FROM sys.dm_exec_cached_plans SDECP INNER JOIN sys.dm_exec_requests SDER ON SDECP.plan_handle = SDER.plan_handle INNER JOIN sys.dm_exec_sessions SDES ON SDER.session_id = SDES.session_id CROSS APPLY sys.dm_exec_query_plan(SDECP.plan_handle) AS SDEQP CROSS APPLY sys.dm_exec_plan_attributes(SDECP.plan_handle) AS SDEPA WHERE SDES.login_name = 'bora-PC\bora'
'Peformance Tuning' 카테고리의 다른 글
Index IGNORE_DUP_KEY 옵션 TEST (1) | 2015.09.14 |
---|---|
파티션 테이블 - 문제점, 주의 사항 (0) | 2012.11.19 |
Dynamic Management Views (0) | 2012.01.22 |
Hash Join 제약. (0) | 2011.10.10 |
Dynamic Management Views
출처:http://www.mssqltips.com/sqlservertutorial/273/dynamic-management-views/
Dynamic Management Views (Tools) |
Overview
With the introduction of SQL Server 2005, Microsoft introduced Dynamic Management Views (DMVs) which allow you to get better insight into what is happening in SQL Server. Without these new tools a lot of the information was unavailable or very difficult to obtain.
DMVs are a great tool to help troubleshoot performance related issues and once you understand their power they will become a staple for your Database Administration.
Explanation
The DMVs were introduced in SQL 2005 and with each new release, Microsoft has been adding additional DMVs to help troubleshoot issues. DMVs actually come in two flavors DMVs (dynamic management views) and DMFs (dynamic management functions) and are sometimes classified as DMOs (dynamic management objects). The DMVs act just like any other view where you can select data from them and the DMFs require values to be passed to the function just like any other function.
The DMVs are broken down into the following categories:
- Change Data Capture Related Dynamic Management Views
- Change Tracking Related Dynamic Management Views
- Common Language Runtime Related Dynamic Management Views
- Database Mirroring Related Dynamic Management Views
- Database Related Dynamic Management Views
- Execution Related Dynamic Management Views and Functions
- Extended Events Dynamic Management Views
- Full-Text Search Related Dynamic Management Views
- Filestream-Related Dynamic Management Views (Transact-SQL)
- I/O Related Dynamic Management Views and Functions
- Index Related Dynamic Management Views and Functions
- Object Related Dynamic Management Views and Functions
- Query Notifications Related Dynamic Management Views
- Replication Related Dynamic Management Views
- Resource Governor Dynamic Management Views
- Service Broker Related Dynamic Management Views
- SQL Server Operating System Related Dynamic Management Views
- Transaction Related Dynamic Management Views and Functions
- Security Related Dynamic Management Views
Here are some of the more useful DMVs that you should familiarize yourself with:
- sys.dm_exec_cached_plans - Cached query plans available to SQL Server
- sys.dm_exec_sessions - Sessions in SQL Server
- sys.dm_exec_connections - Connections to SQL Server
- sys.dm_db_index_usage_stats - Seeks, scans, lookups per index
- sys.dm_io_virtual_file_stats - IO statistics for databases and log files
- sys.dm_tran_active_transactions - Transaction state for an instance of SQL Server
- sys.dm_exec_sql_text - Returns TSQL code
- sys.dm_exec_query_plan - Returns query plan
- sys.dm_os_wait_stats - Returns information what resources SQL is waiting on
- sys.dm_os_performance_counters - Returns performance monitor counters related to SQL Server
Additional Information
Here are some additional articles about DMVs.
'Peformance Tuning' 카테고리의 다른 글
파티션 테이블 - 문제점, 주의 사항 (0) | 2012.11.19 |
---|---|
query plan의 실행 옵션 보기 (0) | 2012.01.29 |
Hash Join 제약. (0) | 2011.10.10 |
Join의 종류 (1) | 2011.10.10 |
모니터링::Index 생성 & Rebuild 진행 상황
SQL SERVER 2005 이상
이 수가 줄어드는 것으로 완료되는 진행 상황을 보았었는데..
sys.partitions에서 작업하는 index_id 값에 해당하는 row 수가 전체 table row 값과 동일할 때까지 증가하는 것을 볼 수 있다.
즉, 완료가 되면 전체 table row 수와 같아 진다.
SQL 2005 이상 부터 가능.
DECLARE @TABLE_NAME SYSNAME, @INDEX_ID INT SET @TABLE_NAME = SET @INDEX_ID = -- REBUILD SELECT A.*, B.ROWS, A.ROWS-B.ROWS AS DIFF_ROWS, B.ROWS*100.0/A.ROWS as '%' FROM SYS.PARTITIONS A WITH(NOLOCK) JOIN SYS.PARTITIONS B WITH(NOLOCK) ON A.OBJECT_ID=B.OBJECT_ID AND A.INDEX_ID=B.INDEX_ID AND A.PARTITION_NUMBER=B.PARTITION_NUMBER AND A.ROWS<>B.ROWS WHERE A.OBJECT_ID=OBJECT_ID(@TABLE_NAME) AND A.INDEX_ID= @INDEX_ID AND A.ROWS-B.ROWS>0 -- NEW SELECT * FROM SYS.PARTITIONS WITH(NOLOCK) WHERE OBJECT_ID = OBJECT_ID(@TABLE_NAME) SELECT * FROM SYS.SYSPROCESSES WITH(NOLOCK) WHERE SPID =
'Monitoring' 카테고리의 다른 글
대랑 I/O 사용 세션 쿼리 (0) | 2012.08.13 |
---|---|
TEMPDB의 페이지 사용량 측정 (0) | 2012.08.13 |
T-SQL:: Default Trace로 DB 증가량 확인 (1) | 2011.04.15 |
Admin::Tempdb 의 작업, 모니터링 (0) | 2011.01.30 |
Resource Governor
'Resource Governor' 카테고리의 다른 글
Resource Governor Category View (0) | 2012.08.13 |
---|
MongoDB 설치 - Windows
MongoDB 설치를 정리합니다.
1. OS에 맞는 버전을 다운로드 합니다.
http://www.mongodb.org/downloads
2. 다운로드 한 파일을 압축을 풉니다. 이 압축을 푼 곳이 실행파일이 있는 곳이니 폴더 명을 원하는 대로 변경합니다.
- bin 폴더에 실행 파일들이 있습니다.
- 압축을 푸는 것으로 설치는 사실상 끝입니다. ^^
3. DB 파일을 저장할 곳의 디랙토리를 만듭니다.
- 해당 디렉토리는 쓰기 권한이 존재해야 합니다.
- 저는 D:\MongoDB\DATA\DB 폴더를 만들고 관리자 권한에 쓰기 권한을 줍니다. 서비스가 실행되는 계정에 줘야겠지요!!
4. 몽고 DB 서비스를 시작해 봅니다.
- 어디서든 실행될 수 있게 컴퓨터 환경 변수에 압축을 푼 경로의 bin 폴더를 PATH로 등록합니다.
--dbpath : 기본 경로가 아닌 DB 파일을 DB 파일이 있는 경로를 지정해서 서비스 시작
- MongoDB를 실행한 모습입니다. 서비스가 시작되었으니, 이제 접속해 보면 됩니다.
- 명령창에서 mongo를 실행하면 접속이 됩니다. 자세한 명령어는 메뉴얼을 참고 합니다.
5. Mongo DB 서비스 등록
- 위 처럼 command 로 실행해도 되지만 우리는 서비스로 등록을 하겠습니다. 그러면 서비스로 시작과 중지를 제어 할 수 있습니다.
- Mongo DB의 기본 port : 27017 입니다.
--logpath : log paht
--logappend : log를 append 해서 기록
--dbpath : db 파일 위치
--directoryperdb : DB별 디렉토리로 구분
--serviceName: 서비스 등록 이름.
--install : 서비스로 등록
--port : 다른 포트로 지정해서 실행
그 밖의 명령은 c:> mongod /h 로 확인
- Mongodb를 서비스로 등록했습니다. 구문이 잘못 되면 아래 처럼 에러 발생.
- Mongo DB가 사용하는 port로 잘 실행되었는지 확인.
6. 무료 관리 Tool 설치
- Mongo DB를 무료 관리툴이 존재합니다.
- http://www.mongodb.org/display/DOCS/Admin+UIs , 이곳에서 설치해 보면 됩니다.
- 저는 JMOngoBrowser를 설치했습니다.
- 해당 Tool 설치를 위해서는 JRE 가 필요합니다. http://www.oracle.com/technetwork/java/javase/downloads/jre-6u29-download-513650.html
- 설치는 다운 받아서 압축 해지 하면 끝.
- 자세한 사항은 서서히.. 공부하기로 합니다.
'Mongo DB' 카테고리의 다른 글
MongoDB 알아볼까? (1) | 2011.10.19 |
---|