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

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

SQL Server のチューニングについてまとめてみる - その18 - ( とあるプロジェクト向けメモ )

 下記の資料は、SQL Server 2008 ベースですが、SQL Server 2012 以上のエディションにも問題なく適用できる手法です。
The Data Loading Performance Guide

 パーティションテーブルへのデータインポートであれば、下記の部分から参考になります。

Bulk Loading a Partitioned Table

Bulk loading into partitioned tables provides the fastest possible load option. It allows allowing many concurrent bulk load operations to be executed in parallel with minimum coordination overhead. Switching in partitions once the data loading is done as a metadata-only operation.



However, there is a special case you should consider: If you plan to insert data into several partitions at the same time, you can optimize further. In this case, you switch out each partition into its own table. On each of these tables you then use one or more concurrent bulk load operations. This method is illustrated below:

 どのようにテーブルを配置するかなどの SWITH PARTITION する場合の要件が下記のサイトに記載されています。
Transferring Data Efficiently by Using Partition Switching
 同一ファイルグループにしろとか、テーブルを同一のレイアウトにしろとか、制約に関して記載されています。確り読んでおきましょう。

Both tables must exist before the SWITCH operation. The table from which the partition is being moved (the source table) and the table that is receiving the partition (the target table) must exist in the database before you perform the switch operation.

•The receiving partition must exist and it must be empty. Whether you are adding a table as a partition to an already existing partitioned table, or moving a partition from one partitioned table to another, the partition that receives the new partition must exist and it must be an empty partition.

•The receiving nonpartitioned table must exist and it must be empty. If you are reassigning a partition to form one nonpartitioned table, the table that receives the new partition must exist and it must be an empty nonpartitioned table.

•Partitions must be on the same column. If you are switching a partition from one partitioned table to another, both tables must be partitioned on the same column.

•Source and target tables must share the same filegroup. The source and the target table of the ALTER TABLE...SWITCH statement must reside in the same filegroup, and their large-value columns must be stored in the same filegroup. Any corresponding indexes, index partitions, or indexed view partitions must also reside in the same filegroup. However, the filegroup can be different from that of the corresponding tables or other corresponding indexes.

 これでパーティションされたテーブルのデータ移行もさらに高速化できますね。

※会社にもっていく鞄代わりになるものがほしい。

※PCケースか。これいいな♪
[チャムス] CHUMS Laptop Sleeve CD CH60-0932 TBL (True Blue/Navy)

[チャムス] CHUMS Laptop Sleeve CD CH60-0932 TBL (True Blue/Navy)