都内で働くSEの技術的なひとりごと / Technical soliloquy of System Engineer working in Tokyo

都内でサラリーマンやってます。SQL Server を中心とした (2023年からは Azure も。) マイクロソフト系(たまに、OSS系などマイクロソフト以外の技術も...)の技術的なことについて書いています。日々の仕事の中で、気になったことを技術要素関係なく気まぐれに選んでいるので記事内容は開発言語、インフラ等ばらばらです。なお、当ブログで発信、発言は私個人のものであり、所属する組織、企業、団体等とは何のかかわりもございません。ブログの内容もきちんと検証して使用してください。英語の勉強のため、英語の

『『『 SQL Server 2014 Service Pack 2 is now Available !!! ということなので使ってみる 』 の続き、まずは Performance and Scalability Improvements から書いてみる 』の続き、次に Supportability and Diagnostics Improvements について書いてみる。』 の続きを書いてみる

 関東涼しいですね。夏とは思えない気温です。来週もそんなに気温は上がらなそうです。
f:id:koogucc11:20160723131017p:plain

 さて、今回はSQL Server 2014 SP2 のアップデート概要の最終回です。(なんでこうなったのかは不明です。)
ryuchan.hatenablog.com
ryuchan.hatenablog.com
ryuchan.hatenablog.com

 涼しい午前中を利用して、記事を書いてしまいます。

AlwaysON Lease Timeout Logging – Added new logging capability for Lease Timeout messages so that the current time and the expected renewal times are logged. Also a new message was introduced in the SQL Errorlog regarding the timeouts.

 リースのタイムアウト・メッセージの新しいロギング機能を追加されました。エラーログに出力されます。

 ちなみに、下記のバージョンで対応されています。

 追加されるメッセージは下記の通りです。

Error Error Message Cause Corrective Action
19419 The renewal of the lease between availability group ‘%.*ls’ and the Windows Server Failover Cluster failed because the existing lease is no longer valid. The lease worker on the SQL Server side did not get scheduled on time to process event signal from the cluster. Check the CPU utilization on the server as SQL Server lease worker seems to be starving.
19420 The availability group ‘%.*ls’ is explicitly asked to stop the lease renewal. The lease renewal is stopping as a part of bringing the availability group offline. This is informational only.
19421 The renewal of the lease between availability group ‘%.*ls’ and the Windows Server Failover Cluster failed because renewal didn’t happen within lease interval. The lease helper on the cluster side did not signal the SQL Server lease worker on time. Check corresponding availability group resource in WSFC cluster to see if it reported any error.
19422 The renewal of the lease between availability group ‘%.*ls’ and the Windows Server Failover Cluster failed because of a windows error with Error code (‘%d’). The lease worker on SQL Server side failed to renew the lease because of a windows error. Check windows error code and take the corrective action.
19423 The lease of availability group ‘%.*ls’ lease is no longer valid to start the lease renewal process. When the lease worker started processing the excess lease time provided by online call the lease was already expired. This might happened because of scheduling issues. Check the CPU utilization on the server as SQL Server lease worker seems to be starving.
19424 The lease worker of availability group ‘%.*ls’ is now sleeping the excess lease time (%u ms) supplied during online. This is an informational message only. No user action is required. Informational. Extra online time allotted to starting the lease renewal thread and as part of the availability group online routine.

New DMF for retrieving input buffer in SQL Server – A new DMF for retrieving the input buffer for a session/request (sys.dm_exec_input_buffer) is now available. This is functionally equivalent to DBCC INPUTBUFFER.

 DBCC INPUTBUFFER と同様の機能を持つ DMV である、sys.dm_exec_input_buffer が追加されました。プロセスが実行しているコマンドを確認するものです。似たようなものに、sys.fn_get_sql (Transact-SQL) があります。けど、これはもう使っちゃいけません。

Mitigation for underestimated and overestimated memory grant – Added new query hints for Resource Governor through MIN_GRANT_PERCENT and MAX_GRANT_PERCENT (KB3107401). This allows you to leverage these hints while running queries by capping their memory grants to prevent memory contention.

 新しいクエリヒントとして、MIN_GRANT_PERCENT および MAX_GRANT_PERCENT が追加されました。下記のように記述することで使用することができます。

SELECT * FROM Table1 ORDER BY Column1 OPTION (min_grant_percent = 10, max_grant_percent = 50

Better memory grant/usage diagnostics – A new extended event was added to the list of tracing capabilities in SQL Server (query_memory_grant_usage) to track memory grants requested and granted. This provides better tracing and analysis capabilities for troubleshooting query execution issues related to memory grants (KB3107173).

 拡張イベントで query_memory_grant_usage が追加されました。詳しくは下記の URL を参照してください。
https://support.microsoft.com/en-us/kb/3107173

Query execution diagnostics for tempdb spill – Hash Warning and Sort Warnings now have additional columns to track physical I/O statistics, memory used and rows affected. We also introduced a new hash_spill_details extended event. Now you can track more granular information for your hash and sort warnings (KB3107172). This improvement is also now exposed through the XML Query Plans in the form of a new attribute to the SpillToTempDbType complex type (KB3107400). Set statistics on now shows sort worktable statistics.

 TempDB の拡張イベントに関する改善です。詳しくは Web で!(手抜き?)
https://support.microsoft.com/en-us/kb/3107173

AlwaysON XEvents and performance counters to troubleshoot latency – New AlwaysON XEvents and performance counters to improve diagnostics when troubleshooting latency issues with AlwaysON. For more details on how to leverage these XEvents and performance counters please refer to this video.

 AlwaysOn に関する拡張イベントの改善です。詳しくは Web で。
https://support.microsoft.com/en-us/kb/3173156

DROP DDL Support for Replication – SQL Server 2014 SP2 allows a table that’s included as an article in transactional replication publication to be dropped from the database and the publication(s). A table can be dropped only if the allow_drop property is set to TRUE on all the publications that have the table(s) as an article. If the property is set to FALSE for any of the publications that contain the article, then the DROP TABLE operation will fail and report that replicated articles can’t be dropped.(KB 3170123)

 トランザクションレプリケーションでテーブルを複数削除することができます。コマンドは下記の通りです。

exec sp_changepublication @publication = '【Publication Name】', @property = 'allow_drop', @value = 'true'

Improved diagnostics for query execution plans that involve residual predicate pushdown – The actual rows read will now be reported in the query execution plans (KB3107397) to help improve query performance troubleshooting. This should negate the need to capture SET STATISTICS IO separately. This now allows you to see information related to a residual predicate pushdown in a query plan.

 これ、重要です。Predicate と Seek Predicate をまず理解する必要があります。下記の記事に詳しく書いてありますので、参考にしてください。
ryuchan.hatenablog.com

 それでは、実際に試してみましょう。下記のクエリを SQL Server 2014 SP2、データベースは AdventureWorks2014 で実行します。

SELECT
    AddressID,
    AddressLine1,
    AddressLine2,
    City,
    StateProvinceID,
    PostalCode,
    SpatialLocation,
    rowguid,
    ModifiedDate
FROM
    Person.Address
WHERE
    AddressLine1 = N'Attaché de Presse' AND 
    PostalCode = N'75007'

f:id:koogucc11:20160723124447p:plain
 
 さらに、オペレータの内容をみてみましょう。『読み取った行数』が表示されているがわかるかと思います。これは、Predicate(述語)が発生しているときに表示されます。インデックスを使っているのになぜか遅い、とよく質問されるのですが、このパターンはよく見かけます。実際の行数と読み取った行数が一度に表示されるのは、かなりいいですね。これはいい改善です。
f:id:koogucc11:20160723124514p:plain
 
 SQL Server 2014 SP2 のダウンロードはこちら。
Download Microsoft® SQL Server® 2014 Service Pack 2 (SP2) from Official Microsoft Download Center

なんだろ、これ?

沖縄 オトナの社会見学 R18

沖縄 オトナの社会見学 R18

『『 SQL Server 2014 Service Pack 2 is now Available !!! ということなので使ってみる 』 の続き、まずは Performance and Scalability Improvements から書いてみる 』の続き、次に Supportability and Diagnostics Improvements について書いてみる。

 なぜか興味を持った SQL Server 2014 SP2 のアップデートの内容。
ryuchan.hatenablog.com
ryuchan.hatenablog.com

 すべての更新内容に興味が沸いたわけではないのですが、なんとなく全部見てみようかと。

Supportability and Diagnostics Improvements

 次はサポータビリティと診断に関する改善です。

Tempdb supportability – A new errorlog message indicating the number of tempdb files and notifying different size/autogrowth of tempdb data files at server startup.

 SQL Server 起動時に下記のようなメッセージが表示されます。

The tempdb database has %ld data file(s).

 あと、複数の TempDB のファイルが異なるサイズ、異なる増加容量をが設定されている場合にも同様にエラーログを出力します。例えば以下のようなふざけた環境で SQL Server を再起動してみます。
f:id:koogucc11:20160719124236p:plain

 ERRORLOG には下記のように出力されます。

The tempdb database has 4 data file(s).
The tempdb database data files are not configured with the same initial size and autogrowth settings. To reduce potential allocation contention, the initial size and autogrowth of the files should be same.

 このあたりのログを見る人はそもそも TempDB の設定をミスらない気がしますが....

Database Instant File Initialization Logging – A new errorlog message indicating that Database Instant File Initialization is enabled/disabled at server startup.

 ファイルの瞬時初期化に関しても TempDB の警告と同様にログに出力されます。詳しくは下記の URL を参照のこと。(試すのが面倒な訳ではありません。)
Database Instant File Initialization

Module names in callstack – The Xevent callstack now includes modules names + offset instead of absolute addresses.

 拡張イベントの出力が変わったようですね。(試すのが面倒な訳ではありません。)

New DMF for incremental statistics – This improvement address connect feedback (797156) to enable tracking the incremental statistics at the partition level. A new DMF sys.dm_db_incremental_stats_properties is introduced to expose information per-partition for incremental stats.

 今までは、sys.dm_db_stats_properties (Transact-SQL) で統計の情報を確認していました。SP2 からは、パーティションごとに増分統計が sys.dm_db_incremental_stats_properties で参照できるようです。

 増分統計については下記の URL を参考にしてください。
blogs.technet.microsoft.com

※試すのが面倒な訳ではありません。

Index Usage DMV behavior updated – This improvement addresses connect feedback (739566) from customers where starting SQL 2014 SP2, rebuilding an index will *not* clear any existing row entry from sys.dm_db_index_usage_stats for that index. The behavior now is to what it was in SQL 2008.

 SQL Server を始めたのが 2008R2 なのであまり意識していませんでした。sys.dm_db_index_usage_stats の扱いが 2008 と同じになったんですね。
※手を抜いているのではありません。

Better correlation between diagnostics XE and DMVs – This improvement addresses connect feedback (1934583). Query_hash and query_plan_hash are used for identifying a query uniquely. DMV defines them as varbinary(8), while XEvent defines them as UINT64. Since SQL server does not have “unsigned bigint”, casting does not always work. This improvement introduces new XEvent action/filter columns equivalent to query_hash and query_plan_hash except they are defined as INT64 which can help correlating queries between XE and DMVs.

 型の統一。sys.dm_exec_requestsとか、sys.dm_exec_query_stats と同じ型の列をもっていなかった......

Support for UTF-8 in BULK INSERT and BCP – This improvement addresses connect feedback (370419) where support for export and import of data encoded in UTF-8 character set is now enabled in BULK INSERT and BCP.

 BULK INSERT で UTF-8 のサポートされました。
BULK INSERT (Transact-SQL)
※850 など、特定のコード ページ番号を指定します。 Important: SQL Server はコード ページ 65001 (UTF-8 エンコード) をサポートしません。

Lightweight per-operator query execution profiling – While troubleshooting query performance, although showplan provides lot of information on the query execution plan and cost of operator in the plan but it has limited information on actual runtime statistics like (CPU, I/O Reads, elapsed time per-thread). SQL 2014 SP2 introduces these additional runtime statistics per operator in the Showplan as well as an XEvent (query_thread_profile) to assist troubleshooting query performance.

blogs.msdn.microsoft.com
 
 あ、これいいですね。今までは、

<RunTimeInformation>
   <RunTimeCountersPerThread Thread="0" ActualRows="8001" ActualEndOfScans="1" ActualExecutions="1" />
</RunTimeInformation>

 SP2 からは、実際に読み込んだ行数、CPU時間、経過時間など詳細な情報が記録されます。これは便利!

<RunTimeInformation>
   <RunTimeCountersPerThread Thread="0" ActualRows="8001" ActualRowsRead="10000000" Batches="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row" ActualElapsedms="965" ActualCPUms="965" ActualScans="1" ActualLogicalReads="26073" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" />
</RunTimeInformation>

Change Tracking Cleanup – A new stored procedure sp_flush_CT_internal_table_on_demand is introduced to cleanup change tracking internal tables on demand.

 手動で変更追跡のテーブルを削除することができます。
変更の追跡について (SQL Server)

f:id:koogucc11:20160719235133j:plain
 飲みながら記事書いていたので、気力が尽きてしまいました。続きはまた別の記事で書きます。残りは下記の通りです。

AlwaysON Lease Timeout Logging – Added new logging capability for Lease Timeout messages so that the current time and the expected renewal times are logged. Also a new message was introduced in the SQL Errorlog regarding the timeouts.

New DMF for retrieving input buffer in SQL Server – A new DMF for retrieving the input buffer for a session/request (sys.dm_exec_input_buffer) is now available. This is functionally equivalent to DBCC INPUTBUFFER.

Mitigation for underestimated and overestimated memory grant – Added new query hints for Resource Governor through MIN_GRANT_PERCENT and MAX_GRANT_PERCENT (KB3107401). This allows you to leverage these hints while running queries by capping their memory grants to prevent memory contention.

Better memory grant/usage diagnostics – A new extended event was added to the list of tracing capabilities in SQL Server (query_memory_grant_usage) to track memory grants requested and granted. This provides better tracing and analysis capabilities for troubleshooting query execution issues related to memory grants (KB3107173).

Query execution diagnostics for tempdb spill – Hash Warning and Sort Warnings now have additional columns to track physical I/O statistics, memory used and rows affected. We also introduced a new hash_spill_details extended event. Now you can track more granular information for your hash and sort warnings (KB3107172). This improvement is also now exposed through the XML Query Plans in the form of a new attribute to the SpillToTempDbType complex type (KB3107400). Set statistics on now shows sort worktable statistics.

AlwaysON XEvents and performance counters to troubleshoot latency – New AlwaysON XEvents and performance counters to improve diagnostics when troubleshooting latency issues with AlwaysON. For more details on how to leverage these XEvents and performance counters please refer to this video.

DROP DDL Support for Replication – SQL Server 2014 SP2 allows a table that’s included as an article in transactional replication publication to be dropped from the database and the publication(s). A table can be dropped only if the allow_drop property is set to TRUE on all the publications that have the table(s) as an article. If the property is set to FALSE for any of the publications that contain the article, then the DROP TABLE operation will fail and report that replicated articles can’t be dropped.(KB 3170123)

Improved diagnostics for query execution plans that involve residual predicate pushdown – The actual rows read will now be reported in the query execution plans (KB3107397) to help improve query performance troubleshooting. This should negate the need to capture SET STATISTICS IO separately. This now allows you to see information related to a residual predicate pushdown in a query plan.

 さぁ、仕事しよう。

 秘密の沖縄スポットガイド。仕事では何回もきてるけど、まだまだ知らないことだらけの、沖縄。

秘密の沖縄スポットガイド

秘密の沖縄スポットガイド

『 SQL Server 2014 Service Pack 2 is now Available !!! ということなので使ってみる 』 の続き、まずは Performance and Scalability Improvements から書いてみる

 前回は少しだけ SQL Server 2014 SP2 について書いてみました。
ryuchan.hatenablog.com

Performance and Scalability Improvements in SQL 2014 SP2

 取り上げてなかったものをさらっとみていきましょう。パフォーマンスとスケーラビリティーの改善についてです。

Automatic Soft NUMA partitioning – With SQL 2014 SP2, Automatic Soft NUMA is introduced when Trace Flag 8079 is enabled at the server level. When Trace Flag 8079 is enabled during startup, SQL Server 2014 SP2 will interrogate the hardware layout and automatically configures Soft NUMA on systems reporting 8 or more CPUs per NUMA node.The automatic soft NUMA behavior is Hyperthread (HT/logical processor) aware. The partitioning and creation of additional nodes scales background processing by increasing the number of listeners, scaling and network and encryption capabilities. It is recommended to first test the performance of workload with Auto-Soft NUMA before it is turned ON in production.

 自動 Soft NUMA についてです。TraceFlag 8079 を有効にすることで実現可能なようです。うーん、ここまで大規模なシステムに生きている間に出会うことはあるんだろうか。製品に適用するには十分な検証が必要ですね。

Dynamic Memory Object Scaling – Dynamically partition memory object based on number of nodes and cores to scale on modern hardware. The goal of dynamic promotion is to automatically partition a thread safe memory object (CMEMTHREAD) if it becomes a bottleneck. Unpartitioned memory objects will be dynamically promoted to be partitioned by node (number of partitions equals number of NUMA nodes) based on the workload and bottleneck, and memory objects partitioned by node can be further promoted to be partitioned by CPU (number of partitions equals number of CPUs). This enhancement eliminates the need of Trace Flag 8048 post SQL 2014 SP2.

 スレッドセーフオブジェクトである CMEMTHREAD の待機を減少させるために、ノード単位に分割させボトルネックを減少させる修正みたいです。Automatic Soft NUMA にも関連するんでしょうか。

Enable >8TB for Buffer Pool – Enabled 128TB Virtual address space for buffer pool usage. This improvement enables SQL Server Buffer Pool to scale beyond 8TB on modern hardware.

 これもまた大規模な話ですね。バッファー プール拡張 を使用した場合はどうなるんでしょう?

SOS_RWLock spinlock Improvement – The SOS_RWLock is a synchronization primitive used in various places throughout the SQL Server code base. As the name implies the code can have multiple shared (readers) or single (writer) ownership. This improvement removes the need for spinlock for SOS_RWLock and instead uses lock-free techniques similar to in-memory OLTP. With this change, many threads can read a data
structure protected by SOS_RWLock in parallel without blocking each other and thereby providing increased scalability. Before this change, the older spinlock implementation allowed only one thread to acquire the SOS_RWLock at a time even to read a data structure.

 内部的な同期オブジェクトによる待機方法をインメモリの似た技術でロックフリーのような仕組みに変更されたようです。今までは、sys.dm_os_spinlock_stats で確認できました。既に SQL Server 2016 には搭載されているようです。下記のサイトで検証内容を確認できます。( 3倍くらいのスループットが出ていることが確認できます。 )
SQL 2016 – It Just Runs Faster: SOS_RWLock Redesign – CSS SQL Server Engineers

Spatial Native Implementation – Significant improvement in spatial query performance which was introduced earlier in SQL 2012 SP3 is now introduced in SQL 2014 SP2 as well through native implementation (KB3107399)

 空間データSpatial Data (SQL Server)に関するパフォーマンスが向上しています。うーん、使ったことないのでいまいちよくわかりません。

九州から東海まで梅雨明けしましたね。来週には関東も梅雨明けするかな。
headlines.yahoo.co.jp

暑い!かき氷!

SQL Server 2014 Service Pack 2 is now Available !!! ということなので使ってみる

 先週から今週とかなり忙しく、週末もまともにブログを書けませんでした。最近、見てなかった SQL Server Blog に「SQL Server 2014 Service Pack 2 is now Available !!! 」とあったので、2014 に対して興味はなかったのですが、ちょっとみてみることにしました。
blogs.msdn.microsoft.com

 個人的に気になったものを二つほどチェックしてみます。

MAXDOP hint for DBCC CHECK* commands – This improvement addresses one of the connect feedback from customers and is useful to run DBCC CHECKDB with MAXDOP setting other than the sp_configure value. If MAXDOP exceeds the value configured with Resource Governor, the Database Engine uses the Resource Governor MAXDOP value, described in ALTER WORKLOAD GROUP (Transact-SQL). All semantic rules used with the max degree of parallelism configuration option are applicable when you use the MAXDOP query hint.

DBCC CHECKDB に MAXDOP 指定できるようになったんですね。下記のように指定します。

DBCC CHECKDB WITH MAXDOP=4;

 簡単に性能差を見てみましょう。使用する PC のスペックは下記の通りです。
f:id:koogucc11:20160717133607p:plain

  • MAXDOP = 1 の場合
    f:id:koogucc11:20160717134550p:plain
  • MAXDOP = 4 の場合
    f:id:koogucc11:20160717134559p:plain

 整合性チェックはバックアップ時などには必須なので、高速化されるのは助かりますね。

Database Cloning – Clone database is a new DBCC command added that allows Microsoft CSS to troubleshoot existing production databases by cloning the schema and metadata without the data. The clone is created with the command DBCC clonedatabase(‘source_database_name’, ‘clone_database_name’). Cloned databases should not be used in production environments. To see if a database has been generated from a clonedatabase you can use the following command, select DATABASEPROPERTYEX(‘clonedb’, ‘isClone’).The return value of 1 indicates the database is created from clonedatabase while 0 indicates it is not a clone.

 これはいいですね。「to troubleshoot existing production databases by cloning the schema and metadata without the data」で、統計情報などが取得できるだけでも、実行プランがおかしくなったときなどに重宝しそうです。試そうと思ったけど、2016 はまだサポートしていないんですね。SQL Server 2014 の環境がない....あとで試そう。それ以外にも魅力的な機能向上があるので、2014の環境も構築しよう。

 記事書き始めたころに地震がありました。下から突き上げるような感じでしたね。
f:id:koogucc11:20160717135551p:plain

備えないと、ですね。

非常用持ち出し袋36点セット リュックタイプの防災セット

非常用持ち出し袋36点セット リュックタイプの防災セット

東京防災

東京防災

どのデータがどのパーティションに属しているか確認してみる

 梅雨明けはまだですが、毎日暑いですね。
f:id:koogucc11:20160710123209p:plain

 今回は、パーティション分割したテーブルのそれぞれのデータがどのパーティションに属しているか確認する方法です。データベースは、WideWorldImporters を使用します。
ryuchan.hatenablog.com
 
 テーブルは Sales.CustomerTransactions を使用します。
f:id:koogucc11:20160710123846p:plain

 パーティション番号を得るために、$PARTITION (Transact-SQL) を使用します。下記のクエリを SQL Server Management Studio で実行してみましょう。

USE WideWorldImporters
SELECT 
    [パーティション番号] = $partition.PF_TransactionDate([TransactionDate]),
    ct.* 
FROM 
    Sales.CustomerTransactions ct

 下図の通り、レコード単位にどのパーティションに属しているのか確認することができます。
f:id:koogucc11:20160710124321p:plain

ためになる本、みたい。

SOFT SKILLS ソフトウェア開発者の人生マニュアル

SOFT SKILLS ソフトウェア開発者の人生マニュアル

発表されたときはすごいなーと思いながらも、多分業務で使うことはしばらくないだろうなーと思っていたら、いきなり使うことになりそうなので急遽列ストアインデックスについてお勉強を始めてみる

 早速お勉強。まず、基本概念から。
列ストア インデックスの説明

SQL Server のインメモリ列ストア インデックスは、列ベースのデータ ストレージと列ベースのクエリ処理を使用して、データを格納および管理します。 列ストア インデックスは、主に一括読み込みと読み取り専用のクエリを実行するデータ ウェアハウスのワークロードで適切に動作します。 従来の行指向ストレージの最大 10 倍のクエリ パフォーマンスと、非圧縮データ サイズの最大 7 倍のデータ圧縮を達成するために列ストア インデックスを使用します。

 一括更新向きなんですね。OLTP 系には不向きなのかな?なんか日本語がわかりづらい。

列セグメントの断片化を低減し、パフォーマンスを高めるために、列ストア インデックスでは、一部のデータおよび削除された行に対応する ID の B-Tree を一時的に行ストア テーブルに格納することがあります。 デルタストア操作は内部で処理されます。 列ストア インデックスは、正しいクエリ結果を返すために、列ストアとデルタストアの両方からのクエリ結果を結合します。
デルタストア
クラスター化列ストア インデックスでのみ使用されるデルタストアは、行数が列ストアに移動できる規模になるまで行を格納する行ストア テーブルです。 デルタストアは、読み込みやその他の DML 操作のパフォーマンスを高めるために、クラスター化列ストア インデックスで使用されます。
大規模な一括読み込みでは、行のほとんどがデルタストアを通らずに列ストアに直接移動します。 一括読み込みの最後に位置する行の数は、行グループの最小サイズである 102,400 行を満たすには足りないことがあります。 この場合、それらの行は列ストアではなくデルタストアに移動します。 102,400 行未満の小規模な一括読み込みでは、すべての行がデルタストアに直接移動します。
デルタストアは、最大行数に達すると閉じられます。 閉じている行グループは、組ムーバー プロセスによって確認されます。 閉じている行グループが見つかると、その行グループが圧縮され、列ストアに格納されます。

 tuple-move というプロセスによって、102,400 以上になったらデルタストアから列ストアに移動するのか。

deltastore
Used with clustered columnstore indexes only, a deltastore is a rowstore table that stores rows until the number of rows is large enough to be moved into the columnstore. A deltastore is used with clustered columnstore indexes to improve performance for loading and other DML operations.
During a large bulk load, most of the rows go directly to the columnstore without passing through the deltastore. Some rows at the end of the bulk load might be too few in number to meet the minimum size of a rowgroup which is 102,400 rows. When this happens, the final rows go to the deltastore instead of the columnstore. For small bulk loads with less than 102,400 rows, all of the rows go directly to the deltastore.
When the deltastore reaches the maximum number of rows, it becomes closed. A tuple-move process checks for closed row groups. When it finds the closed rowgroup, it compresses it and stores it into the columnstore.

 この図がわかりやすいですね。
f:id:koogucc11:20160629023502p:plain

図が示すように、クラスター化列ストア インデックスにデータを読み込むには、SQL Server は次のように動作します。
最大サイズの行グループを列ストアに直接挿入します。 データが読み込まれると、SQL Server は開いている行グループに先着順でデータ行を割り当てます。
それぞれの行グループが最大サイズに到達すると、SQL Server は次の処理を行います。
行グループを CLOSED としてマークします。
デルタストアをバイパスします。
列ストア圧縮を使用する行グループで、それぞれの列セグメントを圧縮します。
圧縮された列セグメントを列ストアに物理的に格納します。
次のように、列ストアまたはデルタストアに残りの行を挿入します。
行数が行グループの最小限の行数の要件を満たしている場合は、行が列ストアに追加されます。
行数が行グループの最小限の行数の要件を満たしていない場合は、行がデルタストアに追加されます。

 非クラスター化列ストア インデックスの場合
f:id:koogucc11:20160629023609p:plain

 ふむ、結構辛そうね。

パフォーマンスに関するヒント
列ストア インデックスを並列で作成するための十分なメモリの計画
列ストア インデックスの作成は、メモリに制限がない限り既定で並列操作になります。 インデックスを並列で作成するには、インデックスを順次作成する場合よりも多くのメモリが必要です。 十分なメモリがある場合、列ストア インデックスの作成には、同じ列で B-Tree を構築する場合の約 1.5 倍の時間がかかります。
列ストア インデックスを作成するために必要なメモリは、列数、文字列型の列数、並列処理の最大限度 (DOP)、およびデータの特性によって異なります。 たとえば、テーブル内の行数が 100 万未満の場合、SQL Server はスレッドを 1 つだけ使用して列ストア インデックスを作成します。
テーブルに 100 万を超える行があり、SQL Server で MAXDOP を使用してインデックスを作成するための十分なメモリ許可を取得できない場合、SQL Server は必要に応じて自動的に MAXDOP を減らし、使用できるメモリ許可に合うように調整します。 場合によっては、メモリが制限された状況でインデックスを構築できるように、DOP を 1 まで小さくする必要があります。

 眠い。今日のカラムストアインデックスのお勉強は以上です。

Type-C 用にケーブル買ってみよう、と思ったけど使い道あるのか?

f:id:koogucc11:20160625190318j:plain

 VGA アダプタも必要です。
http://shopap.lenovo.com/SEUILibrary/controller/e/jpweb/LenovoPortal/ja_JP/catalog.workflow:item.detail?hide_menu_area=true&GroupID=460&Code=4X90K86568shopap.lenovo.com

 yoga mouse ほしいなぁ。日本国内では売ってないんだよな。
www.gizmag.com