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:
- BUIK INSERT や BCP でデータを各テーブルインポートする。(全インポート操作を同時にやればいいですね。)
- ALTER TABLE [パーティションされていないテーブル] SWITCH TO [パーティションされたテーブル] PARTITION [パーティション番号] で元のパーティションへ戻す。
- テンポラリに用意されたテーブルを削除する。
どのようにテーブルを配置するかなどの 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.
これでパーティションされたテーブルのデータ移行もさらに高速化できますね。
※会社にもっていく鞄代わりになるものがほしい。
[チャムス] CHUMS Book Pack Sweat Nylon CH60-0680 Black/Grey (ブラックグレー)
- 出版社/メーカー: CHUMS(チャムス)
- メディア: ウェア&シューズ
- この商品を含むブログを見る
[チャムス] CHUMS Laptop Sleeve CD CH60-0932 TBL (True Blue/Navy)
- 出版社/メーカー: CHUMS(チャムス)
- メディア: ウェア&シューズ
- この商品を含むブログを見る