반응형

컬럼스토어 인덱스 동시성

Column Store Index Concurrency and Isolation Levels

 

  • Version : SQL Server 2012, 2014

 

클러스터 컬럼 스토어와 동시성

클러스터 컬럼스토어 인덱스(Clustered column index(CCI))는 기본적으로 데이터웨어하우스 시나리오에 기반하여 디자인 되어 있다.

 

  • 한 번 쓰고 여러 번 읽기 : CCI는 쿼리 성능에 최적화 되어 있다. 이는 기둥 형식으로 압축된 데이터에서 필요한 컬럼만 가져와서 성능을 높인다.
  • 대량 데이터 가져오기 및 세류(천천히) 데이터 로드 : 인서트 오퍼레이션

 

INSERT / UPDATE를 지원하지만 이러한 작업은 대량의 작업에 최적화 되어 있지 않다. 사실 동시성 경우 DELETE / UPDATE 경우 블록킹이 발생 할 수 있으며 대량의 delta row groups로 이어질 수 있다. 동시성 모델에는 새로운 잠금 리소스 ROWGROUP이 있다.

 

잠금이 발생하는 시나리오에 대해 트랜잭션 격리 수준으로 알아 보자.

 

트랜잭션 격리 수준 지원 (Transaction Isolation levels Supported)

  • Read Uncommitted : 대부분 DW 쿼리에 대한 작업이며 쿼리가 실행 되는 동안 PDW 어플라이언스에서 CCI에 엑세스할 때 read uncommitted 로 DML에 대한 동시성이 차단되지 않도록 한다.
  • Read Committed : 잠금 기반으로 실행되며 DML에 대한 블록킹을 제공한다.

 

RCSI는 하나 이상의 CCI 테이블을 포함하여 사용하는 경우 CCI 이외의 모든 테이블은 read committed 격리 수준에서 non-blocking 의미로 액세스 할 수 있다. 하지만 CCI는 불가능하다.

If RCSI is enabled on the database containing one or more tables with CCI, all tables other than CCI can be accessed with non-blocking semantics under read committed isolation level but not for CCI

 

Example : SQL Server 2014

select

    is_read_committed_snapshot_on, snapshot_isolation_state_desc,snapshot_isolation_state

from sys.databases where name='AdventureWorksDW2012'

 

 

CREATE TABLE [dbo].[T_ACCOUNT](

[accountkey] [int] IDENTITY(1,1) NOT NULL,

[accountdescription] [nvarchar](50) NULL

) ON [PRIMARY]

 

-- create a CCI

CREATE CLUSTERED COLUMNSTORE INDEX ACCOUNT_CCI ON T_ACCOUNT

 

세션 1

세션 2

세션3

use AdventureWorksDW2012

go

 

-- Do a DML transaction on CCI but don't commit

begin tran

    insert into T_ACCOUNT (accountdescription )

    values ('value-1');

   
 

set transaction isolation level read committed

go

 

select * from t_account

--You will see CCI query is blocked on session-1 as shown using the query below

 
   

select

    request_session_id as spid,

    resource_type as rt,

    resource_database_id as rdb,

    (case resource_type

        WHEN 'OBJECT' then object_name(resource_associated_entity_id)

        WHEN 'DATABASE' then ' '

        ELSE (select object_name(object_id)

            from sys.partitions

            where hobt_id=resource_associated_entity_id)

    END) as objname,

    resource_description as rd,

    request_mode as rm,

    request_status as rs

from sys.dm_tran_locks

 

 

이 데이터베이스는 기본적으로 non-blocking read committed 격리 수준의 행 버전 관리를 사용하지만 CCI는 잠금 기반의 read committed로 접근한다.

 

  • Snapshot Isolation : 이는 CCI를 포함하는 데이터베이스에서 사용 할 수 있다. CCI 이외의 디스크 기반 테이블은 스냅샷 격리에서 액세스 할 수 있지만 CCI에 대한 액세스가 허용되지 않으며 다음과 같은 에러가 발생한다.

Msg 35371, Level 16, State 1, Line 26

SNAPSHOT isolation level is not supported on a table which has a clustered columnstore index.

 

  • Repeatable Read : CCI에서 지원

set transaction isolation level repeatable read

go

 

begin tran

select * from t_account

 

 

Serializable : CCI에서 지원

set transaction isolation level serializable

go

 

begin tran

    select * from t_account

go

 

 

 

 

[참고자료]

http://blogs.msdn.com/b/sqlserverstorageengine/archive/2014/07/27/clustered-column-store-index-concurrency-and-isolation-level.aspx

 

 

2014-09-23 / 강성욱 / http://sqlmvp.kr

 

SQL Server 2012, 컬럼스토어 인덱스, 행 그룹, Column Store Index, 메모리 인덱스, SQL, 데이터베이스, 대용량 데이터베이스, Delta Row Group, Compress Row Group, 트랜잭션 격리수즌, read uncommitted, transaction isolation level, 스냅샷 격리수준

반응형

+ Recent posts