Real-time data ingestion in Synapse SQL dedicated pool at scale

Published Apr 14 2022 11:21 AM 4,499 Views
Microsoft

This article reviews a common pattern of streaming data (i.e. real-time message ingestion) in Synapse SQL dedicated pool. It opens a discussion on the simple standard way to implement this, as well as the challenges and drawbacks. It then presents an alternate solution which enables optimal performance and greatly reduces maintenance tasks when using clustered column store indexes. This is aimed at developers, DBAs, architects, and anyone who works with streams of data that are captured in real-time.

 

Scenario description

Description of this scenario is as follow: we have messages produced by sensors (simulated by Azure container instances) sent to an Event Hub, then processed by an ASA job which redirects its output into a Synapse table named “rawdata”. At this stage there are two options:

  • query directly “rawdata” table.
  • use “rawdata” as a staging table, then build a pipeline that process the data every ten minutes and store it in a final fact table. It consists of an UPSERT statement to ensure existing records are updated (in case they are resent), otherwise inserts them into a final fact table named “rawdata_fact”.

 

General solution Design Architecture

Picture2.png

 

Building blocks of the current solution can be found on the following link

streaming-at-scale/eventhubs-streamanalytics-azuresql at main · Azure-Samples/streaming-at-scale (gi...

This sample deploys within one resource group:

  • Container instances simulating IoT devices sending their temperature and amount of CO2.
  • Event Hub ingesting messages in real time.
  • Stream Analytics job preprocessing messages and redirect them into Synapse SQL dedicated pool.

How to handle the data ingested

In case ASA job loads data directly in the fact table and assuming it has a clustered column store index, what happens is:

  • no delta store compression can take place as the table is constantly inserted
  • simultaneous COPY INTO statements issued by ASA job can potentially trigger new delta stores creation, hence reduce the performance and/or require index maintenance tasks.

 

See illustration below which shows this:

Picture3.png

 

In case ASA job loads the telemetry data into a staging table named "rawdata" then upsert the fact table, we can see that what happens is the following:

  • there is one delta store per distribution where the insertions land, and no closed rowgroup hence all others are compressed rowgroups.
  • the tuple mover at each compute node ensures that once the delta stores get filled up they are converted in compressed rowgroups.

See illustration below which shows this:

Picture4.png

This task is constituted of:

  • A simple pipeline with a stored procedure activity.

 

 

 

{
    "name": "processrawdata",
    "type": "SqlPoolStoredProcedure",
    "dependsOn": [],
    "policy": {
        "timeout": "7.00:00:00",
        "retry": 0,
        "retryIntervalInSeconds": 30,
        "secureOutput": false,
        "secureInput": false
    },
    "userProperties": [],
    "sqlPool": {
        "referenceName": "sqlpool2",
        "type": "SqlPoolReference"
    },
    "typeProperties": {
        "storedProcedureName": "[dbo].[processrawdata]"
    }
}

 

 

 

  • A tumbling windows trigger that runs the pipeline every 10 minutes.

 

 

 

{
    "name": "tumblingwindow10minutes",
    "properties": {
        "annotations": [],
        "runtimeState": "Stopped",
        "pipeline": {
            "pipelineReference": {
                "referenceName": "processrawdata",
                "type": "PipelineReference"
            }
        },
        "type": "TumblingWindowTrigger",
        "typeProperties": {
            "frequency": "Minute",
            "interval": 10,
            "startTime": "2022-01-14T12:58:00Z",
            "delay": "00:00:00",
            "maxConcurrency": 50,
            "retryPolicy": {
                "intervalInSeconds": 30
            },
            "dependsOn": []
        }
    }
}

 

 

 

  • a stored procedure scheduled to update the fact from the staging:

 

 

 

ALTER PROC [dbo].[processrawdata] AS
BEGIN 
begin TRANSACTION
	--We ensure the staging data is locked before its data gets either insert or update the fact table to avoid inconsistencies
    UPDATE rawdata SET partitionid=0 WHERE 1=0 
	--Now the fact update can take place as well as the stating data when processed
    MERGE dbo.rawdata_fact AS macible 
    USING dbo.rawdata AS masource
    ON (macible.eventId = masource.eventId
	and macible.[Type]=masource.[Type] 
	and macible.DeviceId=masource.DeviceId 
	and macible.DeviceSequenceNumber=masource.DeviceSequenceNumber 
	and macible.CreatedAt=masource.CreatedAt) 
    WHEN MATCHED
    THEN UPDATE SET
        macible.EventId=masource.EventId,
        macible.[Type]=masource.[Type],
        macible.DeviceId=masource.DeviceId,
        macible.DeviceSequenceNumber=masource.DeviceSequenceNumber,
        macible.CreatedAt=masource.CreatedAt,
        macible.[Value]=masource.[Value],
        macible.ComplexData=masource.ComplexData,
        macible.EnqueuedAt=masource.EnqueuedAt,
        macible.ProcessedAt=masource.ProcessedAt,
        macible.StoredAt=masource.StoredAt
        WHEN NOT MATCHED BY TARGET THEN  
    INSERT ([EventId]
            ,[Type]
            ,[DeviceId]
            ,[DeviceSequenceNumber]
            ,[CreatedAt]
            ,[Value]
            ,[ComplexData]
            ,[EnqueuedAt]
            ,[ProcessedAt]
            ,[StoredAt]
            ,[PartitionId]) 
    VALUES
            (masource.[EventId]
            ,masource.[Type]
            ,masource.[DeviceId]
            ,masource.[DeviceSequenceNumber]
            ,masource.[CreatedAt]
            ,masource.[Value]
            ,masource.[ComplexData]
            ,masource.[EnqueuedAt]
            ,masource.[ProcessedAt]
            ,masource.[StoredAt]
            ,masource.[PartitionId]);
    delete from rawdata;
commit TRAN;
END

 

 

 

Then we can a simple view on to of both tables so we have the latest data as well as the processed one:

 

 

 

CREATE  VIEW [dbo].[v_rawdata]
AS select * from rawdata 
union ALL
select * from rawdata_fact;

 

 

 

And monitor in near real time the average temperature and CO2 values:

 

 

 

select type, avg(value) as average
from v_rawdata 
group by type

 

 

 

Takeaways

We can stream data directly from Stream Analytics into a Synapse SQL dedicated pool. We can avoid the clustered store index maintenance by using an intermediate table and a scheduled pipeline.

%3CLINGO-SUB%20id%3D%22lingo-sub-3268436%22%20slang%3D%22en-US%22%3EReal-time%20data%20ingestion%20in%20Synapse%20SQL%20dedicated%20pool%20at%20scale%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3268436%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20reviews%20a%20common%20pattern%20of%20streaming%20data%20(i.e.%20real-time%20message%20ingestion)%20in%20Synapse%20SQL%20dedicated%20pool.%20It%20opens%20a%20discussion%20on%20the%20simple%20standard%20way%20to%20implement%20this%2C%20as%20well%20as%20the%20challenges%20and%20drawbacks.%20It%20then%20presents%20an%20alternate%20solution%20which%20enables%20optimal%20performance%20and%20greatly%20reduces%20maintenance%20tasks%20when%20using%20clustered%20column%20store%20indexes.%20This%20is%20aimed%20at%20developers%2C%20DBAs%2C%20architects%2C%20and%20anyone%20who%20works%20with%20streams%20of%20data%20that%20are%20captured%20in%20real-time.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-392953526%22%20id%3D%22toc-hId-415865777%22%3EScenario%20description%3C%2FH2%3E%0A%3CP%3EDescription%20of%20this%20scenario%20is%20as%20follow%3A%20we%20have%20messages%20produced%20by%20sensors%20(simulated%20by%20Azure%20container%20instances)%20sent%20to%20an%20Event%20Hub%2C%20then%20processed%20by%20an%20ASA%20job%20which%20redirects%20its%20output%20into%20a%20Synapse%20table%20named%20%E2%80%9Crawdata%E2%80%9D.%20At%20this%20stage%20there%20are%20two%20options%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Equery%20directly%20%E2%80%9Crawdata%E2%80%9D%20table.%3C%2FLI%3E%0A%3CLI%3Euse%20%E2%80%9Crawdata%E2%80%9D%20as%20a%20staging%20table%2C%20then%20build%20a%20pipeline%20that%20process%20the%20data%20every%20ten%20minutes%20and%20store%20it%20in%20a%20final%20fact%20table.%20It%20consists%20of%20an%20UPSERT%20statement%20to%20ensure%20existing%20records%20are%20updated%20(in%20case%20they%20are%20resent)%2C%20otherwise%20inserts%20them%20into%20a%20final%20fact%20table%20named%20%E2%80%9Crawdata_fact%E2%80%9D.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1414500937%22%20id%3D%22toc-hId--1391588686%22%3EGeneral%20solution%20Design%20Architecture%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Picture2.png%22%20style%3D%22width%3A%20605px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358952iC534375C3A18486E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Picture2.png%22%20alt%3D%22Picture2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1073011896%22%20id%3D%22toc-hId-1095924147%22%3EBuilding%20blocks%20of%20the%20current%20solution%20can%20be%20found%20on%20the%20following%20link%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2Fstreaming-at-scale%2Ftree%2Fmain%2Feventhubs-streamanalytics-azuresql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Estreaming-at-scale%2Feventhubs-streamanalytics-azuresql%20at%20main%20%C2%B7%20Azure-Samples%2Fstreaming-at-scale%20(github.com)%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EThis%20sample%26nbsp%3Bdeploys%20within%20one%20resource%20group%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EContainer%20instances%20simulating%20IoT%20devices%20sending%20their%20temperature%20and%20amount%20of%20CO2.%3C%2FLI%3E%0A%3CLI%3EEvent%20Hub%20ingesting%20messages%20in%20real%20time.%3C%2FLI%3E%0A%3CLI%3EStream%20Analytics%20job%20preprocessing%20messages%20and%20redirect%20them%20into%20Synapse%20SQL%20dedicated%20pool.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId--734442567%22%20id%3D%22toc-hId--711530316%22%3EHow%20to%20handle%20the%20data%20ingested%3C%2FH2%3E%0A%3CP%3EIn%20case%20ASA%20job%20loads%20data%20directly%20in%20the%20fact%20table%20and%20assuming%20it%20has%20a%20clustered%20column%20store%20index%2C%20what%20happens%20is%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Eno%20delta%20store%20compression%20can%20take%20place%20as%20the%20table%20is%20constantly%20inserted%3C%2FLI%3E%0A%3CLI%3Esimultaneous%20COPY%20INTO%20statements%20issued%20by%20ASA%20job%20can%20potentially%20trigger%20new%20delta%20stores%20creation%2C%20hence%20reduce%20the%20performance%20and%2For%20require%20index%20maintenance%20tasks.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20illustration%20below%20which%20shows%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Picture3.png%22%20style%3D%22width%3A%20605px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358954i554DE7AEC176DE11%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Picture3.png%22%20alt%3D%22Picture3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20case%20ASA%20job%20loads%20the%20telemetry%20data%20into%20a%20staging%20table%20named%20%22rawdata%22%20then%20upsert%20the%20fact%20table%2C%20we%20can%20see%20that%20what%20happens%20is%20the%20following%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Ethere%20is%20one%20delta%20store%20per%20distribution%20where%20the%20insertions%20land%2C%20and%20no%20closed%20rowgroup%20hence%20all%20others%20are%20compressed%20rowgroups.%3C%2FLI%3E%0A%3CLI%3Ethe%20tuple%20mover%20at%20each%20compute%20node%20ensures%20that%20once%20the%20delta%20stores%20get%20filled%20up%20they%20are%20converted%20in%20compressed%20rowgroups.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ESee%20illustration%20below%20which%20shows%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Picture4.png%22%20style%3D%22width%3A%20605px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358955i26F751A165AC4F44%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Picture4.png%22%20alt%3D%22Picture4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20task%20is%20constituted%20of%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EA%20simple%20pipeline%20with%20a%20stored%20procedure%20activity.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22name%22%3A%20%22processrawdata%22%2C%0A%20%20%20%20%22type%22%3A%20%22SqlPoolStoredProcedure%22%2C%0A%20%20%20%20%22dependsOn%22%3A%20%5B%5D%2C%0A%20%20%20%20%22policy%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22timeout%22%3A%20%227.00%3A00%3A00%22%2C%0A%20%20%20%20%20%20%20%20%22retry%22%3A%200%2C%0A%20%20%20%20%20%20%20%20%22retryIntervalInSeconds%22%3A%2030%2C%0A%20%20%20%20%20%20%20%20%22secureOutput%22%3A%20false%2C%0A%20%20%20%20%20%20%20%20%22secureInput%22%3A%20false%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22userProperties%22%3A%20%5B%5D%2C%0A%20%20%20%20%22sqlPool%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22referenceName%22%3A%20%22sqlpool2%22%2C%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22SqlPoolReference%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22typeProperties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22storedProcedureName%22%3A%20%22%5Bdbo%5D.%5Bprocessrawdata%5D%22%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EA%20tumbling%20windows%20trigger%20that%20runs%20the%20pipeline%20every%2010%20minutes.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22name%22%3A%20%22tumblingwindow10minutes%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22annotations%22%3A%20%5B%5D%2C%0A%20%20%20%20%20%20%20%20%22runtimeState%22%3A%20%22Stopped%22%2C%0A%20%20%20%20%20%20%20%20%22pipeline%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22pipelineReference%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22referenceName%22%3A%20%22processrawdata%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22PipelineReference%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22TumblingWindowTrigger%22%2C%0A%20%20%20%20%20%20%20%20%22typeProperties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22frequency%22%3A%20%22Minute%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22interval%22%3A%2010%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22startTime%22%3A%20%222022-01-14T12%3A58%3A00Z%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22delay%22%3A%20%2200%3A00%3A00%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22maxConcurrency%22%3A%2050%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22retryPolicy%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22intervalInSeconds%22%3A%2030%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22dependsOn%22%3A%20%5B%5D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Ea%20stored%20procedure%20scheduled%20to%20update%20the%20fact%20from%20the%20staging%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3EALTER%20PROC%20%5Bdbo%5D.%5Bprocessrawdata%5D%20AS%0ABEGIN%20%0Abegin%20TRANSACTION%0A%20--We%20ensure%20the%20staging%20data%20is%20locked%20before%20its%20data%20gets%20either%20insert%20or%20update%20the%20fact%20table%20to%20avoid%20inconsistencies%0A%20%20%20%20UPDATE%20rawdata%20SET%20partitionid%3D0%20WHERE%201%3D0%20%0A%20--Now%20the%20fact%20update%20can%20take%20place%20as%20well%20as%20the%20stating%20data%20when%20processed%0A%20%20%20%20MERGE%20dbo.rawdata_fact%20AS%20macible%20%0A%20%20%20%20USING%20dbo.rawdata%20AS%20masource%0A%20%20%20%20ON%20(macible.eventId%20%3D%20masource.eventId%0A%20and%20macible.%5BType%5D%3Dmasource.%5BType%5D%20%0A%20and%20macible.DeviceId%3Dmasource.DeviceId%20%0A%20and%20macible.DeviceSequenceNumber%3Dmasource.DeviceSequenceNumber%20%0A%20and%20macible.CreatedAt%3Dmasource.CreatedAt)%20%0A%20%20%20%20WHEN%20MATCHED%0A%20%20%20%20THEN%20UPDATE%20SET%0A%20%20%20%20%20%20%20%20macible.EventId%3Dmasource.EventId%2C%0A%20%20%20%20%20%20%20%20macible.%5BType%5D%3Dmasource.%5BType%5D%2C%0A%20%20%20%20%20%20%20%20macible.DeviceId%3Dmasource.DeviceId%2C%0A%20%20%20%20%20%20%20%20macible.DeviceSequenceNumber%3Dmasource.DeviceSequenceNumber%2C%0A%20%20%20%20%20%20%20%20macible.CreatedAt%3Dmasource.CreatedAt%2C%0A%20%20%20%20%20%20%20%20macible.%5BValue%5D%3Dmasource.%5BValue%5D%2C%0A%20%20%20%20%20%20%20%20macible.ComplexData%3Dmasource.ComplexData%2C%0A%20%20%20%20%20%20%20%20macible.EnqueuedAt%3Dmasource.EnqueuedAt%2C%0A%20%20%20%20%20%20%20%20macible.ProcessedAt%3Dmasource.ProcessedAt%2C%0A%20%20%20%20%20%20%20%20macible.StoredAt%3Dmasource.StoredAt%0A%20%20%20%20%20%20%20%20WHEN%20NOT%20MATCHED%20BY%20TARGET%20THEN%20%20%0A%20%20%20%20INSERT%20(%5BEventId%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BType%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BDeviceId%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BDeviceSequenceNumber%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BCreatedAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BValue%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BComplexData%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BEnqueuedAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BProcessedAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BStoredAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2C%5BPartitionId%5D)%20%0A%20%20%20%20VALUES%0A%20%20%20%20%20%20%20%20%20%20%20%20(masource.%5BEventId%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BType%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BDeviceId%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BDeviceSequenceNumber%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BCreatedAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BValue%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BComplexData%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BEnqueuedAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BProcessedAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BStoredAt%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2Cmasource.%5BPartitionId%5D)%3B%0A%20%20%20%20delete%20from%20rawdata%3B%0Acommit%20TRAN%3B%0AEND%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20we%20can%20a%20simple%20view%20on%20to%20of%20both%20tables%20so%20we%20have%20the%20latest%20data%20as%20well%20as%20the%20processed%20one%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ECREATE%20%20VIEW%20%5Bdbo%5D.%5Bv_rawdata%5D%0AAS%20select%20*%20from%20rawdata%20%0Aunion%20ALL%0Aselect%20*%20from%20rawdata_fact%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20monitor%20in%20near%20real%20time%20the%20average%20temperature%20and%20CO2%20values%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Eselect%20type%2C%20avg(value)%20as%20average%0Afrom%20v_rawdata%20%0Agroup%20by%20type%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1753070266%22%20id%3D%22toc-hId-1775982517%22%3ETakeaways%3C%2FH2%3E%0A%3CP%3EWe%20can%20stream%20data%20directly%20from%20Stream%20Analytics%20into%20a%20Synapse%20SQL%20dedicated%20pool.%26nbsp%3BWe%20can%20avoid%20the%20clustered%20store%20index%20maintenance%20by%20using%20an%20intermediate%20table%20and%20a%20scheduled%20pipeline.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3268436%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20use%20case%20is%20about%20streaming%20data%20in%20Synapse%20SQL%20dedicated%20pool%20leveraging%20Event%20Hubs%2C%20Stream%20Analytics%20and%20minimize%20the%20maintenance%20of%20the%20fact%20table%20receiving%20the%20telemetry%20data%20when%20using%20a%20clustered%20column%20store%20index%20to%20provide%20best%20performance.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Picture2.png%22%20style%3D%22width%3A%20605px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358953iB34E56A9F073DC4A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Picture2.png%22%20alt%3D%22Picture2.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-3268436%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20SQL%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 26 2022 11:45 AM
Updated by: