How to maximize COPY load throughput with file splits

Published Apr 17 2020 07:15 AM 3,292 Views
Microsoft

Data loading is the first experience data engineers go through when onboarding SQL analytics workloads using Azure Synapse. We recently released the COPY statement to ensure this experience is simple, flexible and fast.

 

It’s recommended to load multiple files at once for parallel processing and maximizing bulk loading performance with SQL pools using the COPY statement. File-splitting guidance is outlined in the following documentation and this blog covers how to easily split CSV files residing in your data lake using Azure Data Factory Mapping data flows within your data pipeline.

 

This example is for a SQL pool configured at a DW6000c which means we should have 720 file splits for optimal load performance. We will be generating 720 file splits out of 60 files. This assumes you have CSV files to split in your data lake and a data factory to create your data pipeline.

 

1. Navigate to your Azure Data Factory and add a data flow

split_1.png

 

2. Fill out the data flow source where your file(s) are stored

split_2.png

 

In this example, the container is “staging” where a wildcard is specified for the 60 text files in the 1TBLineitem60SplitsSingleStringDelimited folder.

 

3. Add a destination sink to your source where you will be storing your file splits and specify the number of partitions (these are your file splits)

split_3.png


4. Add your data flow to a pipeline, configure your compute for your data flow, and manually trigger your pipeline

split_4.png

 

Using “Trigger now” to start the split process will use the specified compute for your data flow. Note using “Debug” will automatically use your debug cluster which by default is an eight-core general compute cluster.

 

5. You can monitor your pipeline and data flow by going to the “Monitor” tab

split_5.png

 

 

This process works for compressed files as well where you only need to specify the compression type in the sink and source dataset.

 

You can then orchestrate your pipeline on a schedule to split files as they land in your sink and add the COPY activity with the COPY command to your pipeline to load into your SQL pool. For additional data loading best practices, refer to the following documentation.

%3CLINGO-SUB%20id%3D%22lingo-sub-1314474%22%20slang%3D%22en-US%22%3EHow%20to%20maximize%20COPY%20load%20throughput%20with%20file%20splits%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1314474%22%20slang%3D%22en-US%22%3E%3CP%3EData%20loading%20is%20the%20first%20experience%20data%20engineers%20go%20through%20when%20onboarding%20SQL%20analytics%20workloads%20using%20Azure%20Synapse.%20We%20recently%20released%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Fcopy-into-transact-sql%3Fview%3Dazure-sqldw-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECOPY%20statement%3C%2FA%3E%20to%20ensure%20this%20experience%20is%20simple%2C%20flexible%20and%20fast.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20recommended%20to%20load%20multiple%20files%20at%20once%20for%20parallel%20processing%20and%20maximizing%20bulk%20loading%20performance%20with%20SQL%20pools%20using%20the%20COPY%20statement.%20File-splitting%20guidance%20is%20outlined%20in%20the%20following%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Fcopy-into-transact-sql%3Fview%3Dazure-sqldw-latest%23what-is-the-file-splitting-guidance-for-the-copy-command-loading-csv-files%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edocumentation%3C%2FA%3E%20and%20this%20blog%20covers%20how%20to%20easily%20split%20CSV%20files%20residing%20in%20your%20data%20lake%20using%20Azure%20Data%20Factory%20Mapping%20data%20flows%20within%20your%20data%20pipeline.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20example%20is%20for%20a%20SQL%20pool%20configured%20at%20a%20DW6000c%20which%20means%20we%20should%20have%20720%20file%20splits%20for%20optimal%20load%20performance.%20We%20will%20be%20generating%20720%20file%20splits%20out%20of%2060%20files.%20This%20assumes%20you%20have%20CSV%20files%20to%20split%20in%20your%20data%20lake%20and%20a%20data%20factory%20to%20create%20your%20data%20pipeline.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Navigate%20to%20your%20Azure%20Data%20Factory%20and%20add%20a%20data%20flow%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22split_1.png%22%20style%3D%22width%3A%20652px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184900iDE7353C7CB762DB1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22split_1.png%22%20alt%3D%22split_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20Fill%20out%20the%20data%20flow%20source%20where%20your%20file(s)%20are%20stored%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22split_2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184902iFA0956CF5177C675%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22split_2.png%22%20alt%3D%22split_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20example%2C%20the%20container%20is%20%E2%80%9Cstaging%E2%80%9D%20where%20a%20wildcard%20is%20specified%20for%20the%2060%20text%20files%20in%20the%201TBLineitem60SplitsSingleStringDelimited%20folder.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%20Add%20a%20destination%20sink%20to%20your%20source%20where%20you%20will%20be%20storing%20your%20file%20splits%20and%20specify%20the%20number%20of%20partitions%20(these%20are%20your%20file%20splits)%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22split_3.png%22%20style%3D%22width%3A%20951px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184903i6EAA114656AC771B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22split_3.png%22%20alt%3D%22split_3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E4.%20Add%20your%20data%20flow%20to%20a%20pipeline%2C%20configure%20your%20compute%20for%20your%20data%20flow%2C%20and%20manually%20trigger%20your%20pipeline%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22split_4.png%22%20style%3D%22width%3A%20791px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184904i92921514A8D4BF0D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22split_4.png%22%20alt%3D%22split_4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUsing%20%E2%80%9CTrigger%20now%E2%80%9D%20to%20start%20the%20split%20process%20will%20use%20the%20specified%20compute%20for%20your%20data%20flow.%20Note%20using%20%E2%80%9CDebug%E2%80%9D%20will%20automatically%20use%20your%20debug%20cluster%20which%20by%20default%20is%20an%20eight-core%20general%20compute%20cluster.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E5.%20You%20can%20monitor%20your%20pipeline%20and%20data%20flow%20by%20going%20to%20the%20%E2%80%9CMonitor%E2%80%9D%20tab%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22split_5.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184905iA9DB45EC7DDBC34C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22split_5.png%22%20alt%3D%22split_5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20process%20works%20for%20compressed%20files%20as%20well%20where%20you%20only%20need%20to%20specify%20the%20compression%20type%20in%20the%20sink%20and%20source%20dataset.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20then%20orchestrate%20your%20pipeline%20on%20a%20schedule%20to%20split%20files%20as%20they%20land%20in%20your%20sink%20and%20add%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fconnector-azure-sql-data-warehouse%23use-copy-statement%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECOPY%20activity%20with%20the%20COPY%20command%3C%2FA%3E%20to%20your%20pipeline%20to%20load%20into%20your%20SQL%20pool.%20For%20additional%20data%20loading%20best%20practices%2C%20refer%20to%20the%20following%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsynapse-analytics%2Fsql-data-warehouse%2Fguidance-for-loading-data%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edocumentation%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1314474%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22split_6.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184916iA3A22E024C5B6775%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22split_6.png%22%20alt%3D%22split_6.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1314474%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20Pipelines%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESynapse%20SQL%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Apr 21 2020 08:04 AM
Updated by: