<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Balu Rathinam on Medium]]></title>
        <description><![CDATA[Stories by Balu Rathinam on Medium]]></description>
        <link>https://medium.com/@balurathinam79?source=rss-347754263a80------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*AmCk0yA50IsbNKxV</url>
            <title>Stories by Balu Rathinam on Medium</title>
            <link>https://medium.com/@balurathinam79?source=rss-347754263a80------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:45:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@balurathinam79/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rethinking SQL Server Agent Scheduling: An On-Demand Orchestration Pattern]]></title>
            <link>https://medium.com/towards-data-engineering/rethinking-sql-server-agent-scheduling-an-on-demand-orchestration-pattern-938b9fa360f6?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/938b9fa360f6</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 19:49:46 GMT</pubDate>
            <atom:updated>2026-07-06T19:49:46.266Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Reducing Unnecessary SQL Server Agent Executions Through Application-Driven Scheduling</strong></h4><p>SQL Server Agent has long been the primary scheduling mechanism for automating recurring database operations. It is commonly used to execute stored procedures, SQL Server Integration Services (SSIS) packages, PowerShell scripts, Python programs, operating system commands, maintenance routines, and many other scheduled workloads.</p><p>For most implementations, the scheduling pattern is straightforward. A job executes at a predefined interval, determines whether work exists, executes the requested workload if necessary, and then exits. This model is simple to configure, reliable, and appropriate for many operational scenarios.</p><p>As systems evolve, however, the number of scheduled jobs often grows alongside the applications they support. Many of these jobs execute every minute or every few minutes, regardless of whether any new work has been submitted. Although each execution may complete within seconds, the scheduler still starts the job, allocates resources, queries the database, records execution history, and performs the same evaluation repeatedly throughout the day.</p><p>The challenge is not the execution time of an individual job. It is the cumulative cost of repeatedly performing work whose only purpose is to determine whether actual work exists.</p><p>In many application architectures, that question has already been answered.</p><p>The application receives the request, validates it, stores the information required for processing, and therefore knows exactly when new work becomes available. Continuously polling the database to rediscover that information becomes an architectural choice rather than a technical necessity.</p><p>This article presents an alternative orchestration pattern that changes how processing begins. Instead of relying on continuous polling, the application activates processing only when work is submitted. SQL Server Agent executes the requested workload, processes all pending requests associated with the current invocation method, and automatically returns to an idle state when processing is complete.</p><p>Although the implementation described throughout this article uses SSIS packages as the business workload, the orchestration pattern itself is independent of SSIS. The same design can be applied to virtually any SQL Server Agent job that executes on a recurring schedule.</p><h3>Design Considerations</h3><p>Replacing a polling-based scheduling model involves more than reducing the number of scheduled executions. Production environments introduce architectural and security constraints that influence how processing can be initiated and managed.</p><p>The orchestration pattern presented here was designed around the following considerations:</p><ul><li>Preserve the existing asynchronous interaction between the application and SQL Server Agent.</li><li>Minimize changes to the existing application architecture.</li><li>Avoid granting Sysadmin privileges to application users or service accounts.</li><li>Support multiple workloads through a common orchestration mechanism.</li><li>Eliminate unnecessary scheduled executions when no work exists.</li><li>Automatically return the scheduling process to an idle state after processing completes.</li><li>Remain fully compatible with SQL Server Agent’s existing security model.</li></ul><p>These considerations influence every architectural decision that follows.</p><p>For example, allowing an application to activate a SQL Server Agent job schedule without elevated server permissions requires careful management of job ownership and execution context. Supporting multiple workloads through a common orchestration mechanism requires orchestration logic to remain independent of business processing. Likewise, returning the scheduler to an idle state requires a reliable mechanism for determining when processing has actually finished.</p><p>Rather than addressing these independently, the architecture combines them into a single orchestration framework that manages request registration, execution control, workload selection, secure execution, and automatic lifecycle management.</p><p>Understanding these constraints provides the context for examining why the traditional scheduling model can become inefficient.</p><h3>Traditional Polling-Based Scheduling</h3><p>Most recurring SQL Server Agent jobs follow the same processing cycle.</p><p>A scheduled execution begins at a predefined interval, checks whether work exists, executes the workload if necessary, and exits. The same sequence repeats at every scheduled interval regardless of whether new requests have been submitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*Z1-uCDpPknSdB4j6e7Az6Q.png" /><figcaption><strong>Figure 1. Polling-Based Scheduling</strong></figcaption></figure><p>The execution cycle itself is not inefficient.</p><p>The inefficiency appears when the cycle repeats continuously even though the application already knows when processing should begin.</p><p>Consider a job scheduled to execute every minute.</p><p>If only a handful of requests are submitted throughout the day, the overwhelming majority of executions simply confirm that no work exists before terminating. As additional jobs are introduced, the scheduler spends an increasing amount of time performing repetitive evaluations instead of executing useful work.</p><p>The workload itself is not the issue.</p><p>Whether the job executes a stored procedure, an SSIS package, a PowerShell script, a Python program, or another SQL Server Agent workload makes little difference. The polling behaviour remains the same.</p><p>The opportunity for improvement lies in changing how execution is initiated rather than changing what executes.</p><h3>From Polling to Application-Driven Scheduling</h3><p>Instead of asking SQL Server Agent to determine when work exists, the responsibility for initiating processing can be transferred to the application.</p><p>This is possible because the application already knows when processing should begin.</p><p>When a user submits a request, uploads a file, or initiates a business operation, the application already possesses all the information required to begin downstream processing. Rather than waiting for the next scheduled execution to discover the request, the application can simply notify SQL Server Agent that work is available.</p><p>This changes the scheduling model considerably.</p><p>Instead of executing continuously and searching for work, SQL Server Agent remains idle until explicitly activated.</p><p>Once activated, it processes every pending request associated with the current invocation method before returning to an idle state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y5PcEpmYvxb8aCexSSSRrw.png" /><figcaption><strong>Figure 2. Polling Compared with On-Demand Scheduling</strong></figcaption></figure><p>The distinction between these approaches is subtle but important.</p><p>In a polling model, SQL Server Agent determines <strong>when</strong> processing should begin.</p><p>In an on-demand model, the application determines <strong>when</strong> processing should begin because it already knows when work has arrived.</p><p>SQL Server Agent continues to perform exactly what it was designed to do — execute scheduled workloads — but it no longer spends time repeatedly determining whether execution is necessary.</p><p>The remainder of the article examines the architecture that enables this behaviour while preserving asynchronous processing, maintaining SQL Server Agent’s security model, and supporting multiple workload types.</p><h3>Architecture Overview</h3><p>Changing how execution begins requires more than enabling and disabling a SQL Server Agent job schedule. The architecture must clearly separate responsibility for identifying new work, controlling execution, and performing business processing.</p><p>The solution consists of five logical components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*PznVCt73hsypzd05Lu_a1g.png" /></figure><p>One design decision deserves particular attention.</p><p>Although referred to as a <strong>Processing Log</strong>, the table serves two distinct purposes.</p><p>Initially, it functions as an audit mechanism by recording processing requests submitted by the application.</p><p>Once processing begins, those same records become the execution queue that determines what should execute next.</p><p>No additional queue infrastructure is required because the information needed for orchestration already exists within the processing records themselves.</p><p>This dual-purpose design simplifies the overall architecture while preserving a complete execution history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*on6k_kdwAohklx4nLcu6TQ.png" /><figcaption><strong>Figure 3. Overall Orchestration Architecture</strong></figcaption></figure><p>The Orchestration Controller intentionally contains no business logic.</p><p>Its responsibility is to determine which workload should execute, supply the required execution parameters, monitor execution status, and decide whether processing should continue or end.</p><p>Keeping orchestration separate from business processing allows new workloads to be introduced without redesigning the orchestration framework itself.</p><p>The next section follows a single request through the complete execution lifecycle, from the moment it is submitted until SQL Server Agent returns to an idle state.</p><h3>Execution Lifecycle</h3><p>The architecture is easier to understand by following a single processing request from submission through completion.</p><h3>Step 1 — Register the Processing Request</h3><p>Processing begins when the application receives a request that requires asynchronous execution.</p><p>Rather than directly invoking the business workload, the application records the request in the Processing Log together with all information required for downstream processing. Depending on the workload, this information may include the invocation method, execution parameters, file names, record identifiers, timestamps, or other metadata required during execution.</p><p>At this point, no business processing has occurred. The request has simply been registered.</p><h3>Step 2 — Activate Processing</h3><p>Immediately after the request has been recorded, the application programmatically enables the SQL Server Agent job schedule responsible for orchestration.</p><p>The application does not execute the workload itself, nor does it wait for processing to complete. Its responsibility ends after two operations have been performed successfully:</p><ul><li>Register the processing request.</li><li>Enable the SQL Server Agent job schedule.</li></ul><p>This preserves the existing asynchronous interaction between the application and SQL Server Agent while eliminating the need for continuous polling.</p><h3>Step 3 — Start the Orchestration Process</h3><p>Once the schedule has been enabled, SQL Server Agent starts the orchestration job according to its configured schedule.</p><p>The first responsibility of the job is not business processing.</p><p>Instead, it starts the <strong>Orchestration Controller</strong>.</p><p>The controller coordinates execution rather than performing business logic. It determines what should execute, retrieves the required execution parameters, monitors execution status, and controls the overall processing lifecycle.</p><p>Separating orchestration from business processing allows additional workloads to be introduced without changing the orchestration framework itself.</p><h3>Step 4 — Select the Business Workload</h3><p>The Orchestration Controller queries the Processing Log for pending requests associated with the invocation method responsible for the current execution.</p><p>Once a matching request is identified, the controller retrieves the execution parameters and invokes the corresponding business workload.</p><p>The workload itself may be a stored procedure, an SSIS package, a PowerShell script, a Python program, or another SQL Server Agent task.</p><p>The orchestration process remains identical regardless of what is being executed.</p><h3>Step 5 — Update Execution Status</h3><p>After successful execution, the controller updates the processing status within the Processing Log.</p><p>Maintaining execution status serves two purposes.</p><p>First, it provides a complete operational history for monitoring, troubleshooting, and auditing.</p><p>Second, it prevents completed requests from being processed again during future executions.</p><h3>Step 6 — Continue Processing</h3><p>Rather than terminating after a single request, the controller immediately checks whether additional requests remain for the <strong>current invocation method</strong>.</p><p>This distinction is important.</p><p>The controller does not ask whether <strong>any</strong> requests remain in the Processing Log.</p><p>Instead, it determines whether additional requests remain for the invocation method currently being processed.</p><p>If matching requests exist, processing continues immediately without restarting SQL Server Agent.</p><p>Handling multiple requests during a single execution cycle reduces unnecessary job restarts while maintaining logical separation between independent processing methods.</p><h3>Step 7 — Return to an Idle State</h3><p>When no additional requests remain for the current invocation method, the orchestration process reaches its final stage.</p><p>The Orchestration Controller programmatically disables the SQL Server Agent job schedule.</p><p>Disabling the schedule prevents future scheduled executions until another application request explicitly activates processing again.</p><p>The result is a scheduling model in which SQL Server Agent executes only when processing has been requested rather than continuously polling to discover new work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*o0732hLlMILzBfknO-MznA.png" /><figcaption><strong>Figure 4. Execution Lifecycle</strong></figcaption></figure><p>The execution lifecycle introduces one remaining design challenge.</p><p>Although the application can determine when processing should begin, SQL Server Agent restricts who is permitted to enable or disable job schedules.</p><p>Addressing that requirement requires careful use of SQL Server Agent’s existing security model.</p><h3>Security Architecture</h3><p>The orchestration pattern relies on enabling and disabling SQL Server Agent job schedules as part of its normal execution flow. Controlling job schedules, however, is governed by SQL Server Agent’s permission model and requires careful consideration to avoid granting unnecessary administrative privileges.</p><p>By default, schedule management is limited to principals with the appropriate SQL Server Agent permissions. These include the schedule owner, members of the <strong>Sysadmin</strong> server role, and members of the <strong>SQLAgentOperatorRole</strong>, which can enable or disable schedules through the documented SQL Server Agent procedures such as sp_update_schedule.</p><p>Although <strong>SQLAgentOperatorRole</strong> provides a least-privilege alternative to Sysadmin, it grants the ability to manage SQL Server Agent schedules beyond a single application-owned job. For this orchestration pattern, a more restrictive permission boundary is desirable.</p><p>Instead, the application service account is assigned ownership of both the SQL Server Agent job <strong>and its associated schedule</strong>. Aligning ownership of both objects allows the application to enable and disable its own schedule without requiring broader administrative permissions while keeping those permissions scoped only to the jobs owned by the application.</p><p>The execution context introduces another important design consideration.</p><p>Although the application service account owns the SQL Server Agent job and schedule, the business workload should execute under a dedicated operational identity rather than the application account itself.</p><p>For workloads that support SQL Server Agent Proxy Accounts — such as SSIS packages, PowerShell scripts, CmdExec tasks, and similar subsystems — the SQL Server Agent job step executes using a configured <strong>Proxy Account</strong> through the <strong>Run As</strong> option. This separates operational execution from schedule ownership while allowing each identity to perform a single, well-defined responsibility.</p><p>When processing completes, the Orchestration Controller must disable the SQL Server Agent job schedule using the permissions associated with the application service account that owns the schedule. Since the workload executes under the Proxy Account, the request to disable the schedule must execute in the security context of the schedule owner rather than the Proxy Account itself. This is typically achieved using SQL Server’s supported impersonation mechanisms, allowing the schedule update to execute with the permissions of the schedule owner without granting the Proxy Account direct ownership or elevated administrative rights.</p><p>Without this delegated execution context, the business workload would complete successfully, but the attempt to disable the SQL Server Agent job schedule would fail because the executing identity would not possess permission to modify the schedule. As a result, the schedule would remain enabled and continue executing according to its configured interval even though no additional work remained.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*GqeQJHqmK3fgQimjZaSkng.png" /><figcaption><strong>Figure 5. Security Model</strong></figcaption></figure><p>Each identity performs a distinct responsibility.</p><ul><li><strong>Application Service Account</strong> — Owns the SQL Server Agent job and its associated schedule, and controls schedule activation.</li><li><strong>Proxy Account</strong> — Executes the business workload using the required operational credentials.</li><li><strong>Delegated Owner Context</strong> — Performs schedule deactivation using the permissions of the schedule owner.</li></ul><p>This separation preserves the principle of least privilege by limiting each identity to only the permissions required for its specific responsibility rather than relying on broad administrative roles.</p><p><strong>References</strong></p><ul><li><strong>Microsoft Learn — SQL Server Agent Fixed Database Roles</strong> (SQLAgentUserRole, SQLAgentReaderRole, SQLAgentOperatorRole)</li><li><strong>Microsoft Learn — sp_update_schedule (Transact-SQL)</strong></li><li><strong>Microsoft Learn — SQL Server Agent Proxy Accounts</strong></li></ul><h3>Beyond SSIS</h3><p>Although the implementation described in this article uses SSIS packages as the business workload, the orchestration pattern itself is independent of SSIS.</p><p>The Orchestration Controller determines <strong>what</strong> should execute.</p><p>It does not determine <strong>how</strong> the workload is implemented.</p><p>In an SSIS-based environment, the controller launches SSIS packages.</p><p>In another environment, the same controller could execute:</p><ul><li><strong>PowerShell scripts</strong></li><li><strong>Python programs</strong></li><li><strong>CmdExec tasks</strong></li><li><strong>Database maintenance routines</strong></li><li><strong>Command-line utilities</strong></li><li><strong>Custom executable applications</strong></li><li><strong>Transact-SQL stored procedures</strong> <em>(Unlike the preceding job step types, T-SQL job steps cannot use a proxy account. They always execute under the security context of the job owner.)</em></li></ul><p>Only the executed workload changes.</p><p>The orchestration process remains the same.</p><p>This distinction significantly broadens the applicability of the pattern.</p><p>Any SQL Server Agent job that executes on a recurring schedule and first checks whether work exists can potentially adopt the same orchestration model.</p><p>The objective is not to replace existing business processes.</p><p>The objective is to replace unnecessary polling with application-driven scheduling while preserving the existing execution technology.</p><h3>Operational Benefits</h3><p>Each architectural decision contributes to a measurable operational outcome.</p><p>Application-driven scheduling eliminates unnecessary SQL Server Agent executions whose only purpose is determining whether work exists.</p><p>Because processing begins only after requests have been registered, SQL Server Agent no longer performs repeated polling throughout the day to discover pending work.</p><p>Using a centralized Orchestration Controller simplifies operational management by providing a common execution mechanism for multiple business workloads rather than maintaining separate scheduling logic for each process.</p><p>The dual-purpose Processing Log serves both as an execution queue and as a complete operational history, reducing architectural complexity while improving traceability.</p><p>The security model preserves SQL Server Agent’s existing permission boundaries through ownership, Proxy Accounts, and delegated execution rather than elevated server permissions.</p><p>Perhaps most importantly, the existing asynchronous interaction between the application and SQL Server Agent remains unchanged.</p><p>The application continues to submit processing requests without waiting for execution, allowing the orchestration pattern to be introduced with minimal impact on the surrounding application architecture.</p><p>These improvements are achieved without replacing SQL Server Agent or introducing an external orchestration platform.</p><p>The architecture changes only the mechanism used to initiate processing.</p><h3>Conclusion</h3><p>SQL Server Agent has long provided a reliable mechanism for scheduling recurring database operations.</p><p>The orchestration pattern presented in this article does not replace that capability.</p><p>Instead, it changes how scheduled execution is initiated.</p><p>Rather than requiring SQL Server Agent to repeatedly determine whether work exists, responsibility for initiating execution shifts to the application, which already possesses that information.</p><p>Once activated, the Orchestration Controller processes every pending request associated with the current invocation method, updates execution status, and automatically returns the scheduler to an idle state by disabling the SQL Server Agent job schedule when processing has completed.</p><p>Although the implementation described here uses SSIS packages as the business workload, the architectural pattern extends well beyond SSIS.</p><p>The same orchestration process can coordinate stored procedures, PowerShell scripts, Python programs, maintenance routines, command-line utilities, or virtually any workload supported by SQL Server Agent.</p><p>The executed technology may change.</p><p>The orchestration pattern does not.</p><p>By shifting execution from continuous polling to application-driven scheduling, the architecture preserves asynchronous processing, minimizes application changes, reduces unnecessary scheduler activity, improves resource utilization, simplifies operational management, and maintains SQL Server Agent’s existing security model without requiring elevated administrative privileges.</p><p>The most significant architectural change is not the workload being executed.</p><p>It is allowing the application to determine <strong>when</strong> processing should begin while allowing SQL Server Agent to focus exclusively on <strong>executing</strong> the requested work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=938b9fa360f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/rethinking-sql-server-agent-scheduling-an-on-demand-orchestration-pattern-938b9fa360f6">Rethinking SQL Server Agent Scheduling: An On-Demand Orchestration Pattern</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Architecture Starts Before Database Selection]]></title>
            <link>https://medium.com/towards-data-engineering/database-architecture-starts-before-database-selection-ed02b893e7d4?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed02b893e7d4</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[data-architecture]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 10:12:07 GMT</pubDate>
            <atom:updated>2026-07-06T10:12:07.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>Are We Asking the Right Questions?</h3><p><em>“Should we use PostgreSQL?”</em></p><p><em>“Would SQL Server be a better fit?”</em></p><p><em>“Should we build on Databricks?”</em></p><p><em>“Is Lakebase the right direction?”</em></p><p><em>“Should AI capabilities influence our decision?”</em></p><p>These are questions many of us encounter when designing new products or modernizing existing systems.</p><p>They’re all valid questions.</p><p>But over the years, I’ve found myself asking a different question first.</p><p><strong>Are we asking these questions at the right time?</strong></p><p>Perhaps before comparing technologies, we should first understand the product we’re trying to build.</p><h3>Start with the Product, Not the Technology</h3><p>One principle has consistently guided my thinking throughout my career:</p><blockquote><strong><em>Technology should support the product — not define it.</em></strong></blockquote><p>Before discussing databases, I believe it’s worth stepping back and asking a few fundamental questions.</p><p>What business problem is the product solving?</p><p>Who are its users?</p><p>How will they interact with it?</p><p>What capabilities does it need today?</p><p>How might those requirements evolve over time?</p><p>Whether we’re building a healthcare platform, a financial application, a SaaS product, an operational system, a reporting platform, or an AI-powered solution, the product itself should influence every architectural decision that follows.</p><p>Once those answers become clearer, selecting technologies becomes a much more informed conversation.</p><h3>Understand the Workload</h3><p>After understanding the product, the next step is understanding the workload.</p><p>Is the application primarily transactional (OLTP)?</p><p>Is it analytical (OLAP)?</p><p>Is it a hybrid of operational and analytical workloads?</p><p>Will it process streaming events?</p><p>Does it require near real-time analytics?</p><p>These characteristics influence how data is stored, processed, queried, and maintained throughout the application’s lifecycle.</p><h3>Understand the Data</h3><p>Every application has different data characteristics.</p><p>Some require highly relational models with strong referential integrity.</p><p>Others manage semi-structured documents, event streams, time-series data, or rapidly evolving schemas.</p><p>Understanding how the data is created, updated, queried, and retained often narrows the architectural options long before product comparisons begin.</p><h3>Scale Matters — Even for OLTP Systems</h3><p>One consideration that deserves attention early in the design process is scale.</p><p>It’s easy to design for today’s data volume.</p><p>Good architecture also considers tomorrow’s.</p><p>Questions worth exploring include:</p><ul><li>How much data will the application manage?</li><li>How quickly will that data grow?</li><li>How many concurrent users are expected?</li><li>What are the read and write patterns?</li><li>How long will data be retained?</li><li>Will partitioning, archival, or horizontal scaling eventually become necessary?</li></ul><p>Even systems that are clearly transactional can eventually process billions of records. Understanding realistic growth expectations early often helps avoid significant architectural redesign later.</p><h3>Performance Is More Than Speed</h3><p>Performance isn’t simply about executing queries faster.</p><p>It also includes transaction latency, throughput, concurrency, response-time expectations, availability, recovery objectives, maintenance windows, and operational reliability.</p><p>Different products define performance differently, which is why performance requirements should always be considered within the context of the business problem being solved.</p><h3>Consistency and Reliability</h3><p>Not every application has identical consistency requirements.</p><p>Some require immediate transactional consistency.</p><p>Others may tolerate eventual consistency to support greater scalability or distributed deployments.</p><p>Understanding these requirements early helps determine whether a traditional relational architecture, a distributed database, or another architectural approach is the better fit.</p><h3>The Integration Landscape</h3><p>Very few modern applications operate in isolation.</p><p>Today’s systems often integrate with APIs, event platforms, messaging systems, analytics environments, AI services, reporting tools, SaaS applications, and existing enterprise platforms.</p><p>The broader ecosystem matters.</p><p>Where data originates, where it needs to be consumed, and how frequently it moves between systems can influence architectural decisions just as much as the workload itself.</p><p>This is also where concepts such as <strong>data gravity</strong> become increasingly important. As organizations accumulate larger volumes of data within a particular platform or ecosystem, moving that data elsewhere becomes progressively more complex and expensive. Understanding the integration landscape early can significantly simplify future architecture.</p><h3>Operational Considerations</h3><p>An architecture is successful only if it can be operated successfully.</p><p>Monitoring, security, governance, backup and recovery strategies, compliance requirements, operational tooling, and team expertise all contribute to the long-term success of a platform.</p><p>The most technically capable solution isn’t always the most appropriate if it introduces unnecessary operational complexity.</p><h3>Total Cost of Ownership</h3><p>Cost extends well beyond licensing.</p><p>Infrastructure, cloud services, compute, storage, data movement, migration effort, operational support, and long-term maintenance all contribute to the total cost of ownership.</p><p>Evaluating these factors alongside technical requirements provides a more complete architectural perspective.</p><h3>Designing for Tomorrow, Not Just Today</h3><p>One question I’ve started asking more frequently during architecture discussions is:</p><p><strong>Will today’s architectural decision allow the product to evolve tomorrow?</strong></p><p>Not because every application requires artificial intelligence today.</p><p>Not because every product needs vector search, streaming, or advanced analytics immediately.</p><p>But because products evolve.</p><p>Business priorities evolve.</p><p>Customer expectations evolve.</p><p>A platform selected today should ideally allow future capabilities — such as AI-assisted experiences, intelligent search, machine learning, operational analytics, or real-time processing — to be introduced when they become valuable to the product.</p><p>This isn’t about choosing technology because it’s new.</p><p>It’s about choosing an architecture that can adapt.</p><h3>Only Then Does Technology Selection Begin</h3><p>Once the product, workload, data characteristics, scale, performance, consistency requirements, integration landscape, operational considerations, total cost of ownership, and future direction are understood, technology selection becomes far more meaningful.</p><p>A relational database such as PostgreSQL or SQL Server may be an excellent choice for applications requiring strong transactional consistency, mature ecosystems, and robust operational capabilities.</p><p>A modern data platform such as Databricks may be well suited for large-scale analytics, streaming, machine learning, and lakehouse architectures where processing large volumes of diverse data is a primary requirement.</p><p>Lakebase represents an interesting addition to this landscape. As of today, it introduces PostgreSQL-compatible operational database capabilities that integrate closely with the broader Databricks ecosystem. For organizations exploring tighter integration between operational applications and analytical platforms, it presents another architectural option worth evaluating. Like any emerging platform, its capabilities continue to evolve, so architectural decisions should always be based on current product capabilities, workload requirements, and operational objectives.</p><p>It’s also worth recognizing that a <strong>lakehouse is not simply a traditional data warehouse</strong>. A lakehouse is a broader data platform that combines capabilities historically associated with both data lakes and data warehouses, supporting structured, semi-structured, and unstructured data while enabling analytics, streaming, governance, and AI workloads within a unified architecture.</p><p>These technologies aren’t necessarily competing against one another.</p><p>In many modern architectures, they complement one another, with each platform addressing the workload it was designed to solve.</p><h3>One Final Question</h3><p>Architecture is rarely about predicting the future perfectly.</p><p>It’s about making informed decisions while recognizing that requirements will continue to evolve.</p><p>Which brings me to one final question that I’ve started asking during design discussions:</p><p><strong>What happens if we’re wrong?</strong></p><p>Not because we expect failure.</p><p>But because products grow.</p><p>Business priorities change.</p><p>New capabilities emerge.</p><p>Good architecture isn’t only about meeting today’s requirements.</p><p>It’s also about making tomorrow’s changes easier to accommodate.</p><p>Perhaps choosing a database isn’t the most difficult part of architecture.</p><p>Perhaps asking the right questions is.</p><p>I’m genuinely interested in how experienced architects and engineers approach this today.</p><ul><li>What is the first question you ask before anyone starts comparing database technologies?</li><li>Have your architectural decision-making principles changed as AI, lakehouses, streaming platforms, and modern operational databases have become part of the conversation?</li><li>Do you intentionally ask, <strong>“What happens if we’re wrong?”</strong> when evaluating architectural decisions?</li></ul><p>There may not be a single correct answer, and that’s exactly why I’d like to hear different perspectives. I’m looking forward to learning how others approach these decisions in real-world projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed02b893e7d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/database-architecture-starts-before-database-selection-ed02b893e7d4">Database Architecture Starts Before Database Selection</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why a Successful MERGE Broke a Databricks Streaming Pipeline]]></title>
            <link>https://medium.com/towards-data-engineering/why-a-successful-merge-broke-our-databricks-streaming-pipeline-0624c5464e2f?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/0624c5464e2f</guid>
            <category><![CDATA[delta-lake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-ingestion]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[apache-spark]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 12:12:59 GMT</pubDate>
            <atom:updated>2026-06-28T15:09:47.102Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A production postmortem on Delta transaction history, streaming checkpoints, and Lakeflow Declarative Pipelines</em></h4><p><strong>Author’s Note:</strong> The architecture, code examples, and workflow presented in this article have been generalized to illustrate the underlying engineering concepts. Specific implementation details have been simplified, and references to proprietary systems, customer environments, and organization-specific configurations have been removed.</p><h3>TL;DR</h3><p>• <strong>Success isn’t safety. </strong>A MERGE statement completed successfully, but its Delta transaction history caused downstream streaming readers to stop processing.</p><p>• <strong>Reverting code isn’t enough. </strong>Reverting the notebook did not fix the problem because the transaction had already been committed to the Delta log and the pipeline checkpoint continued resuming from the same version.</p><ul><li><strong>Workaround vs. architecture. </strong>The operational solution combined skipChangeCommits with workflow changes, while the preferred long-term architecture is to process delete events inside the pipeline using apply_changes(…, apply_as_deletes=…).</li></ul><h3>Incident Summary</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*osTdzrzNh9jDAGwSfIZHKA.png" /></figure><h3>Introduction</h3><p>Most production incidents begin with something that appears simple.</p><p>In this implementation , the requirement was straightforward. Whenever a record was deleted in the upstream application, it should also disappear from every downstream reporting table so users would no longer see stale data.</p><p>At first, the request seemed like a routine maintenance task. The records already existed in the reporting layer, so removing them appeared to be a matter of executing the appropriate SQL statement.</p><p>Instead, that seemingly simple requirement evolved into a production investigation that touched nearly every layer of the streaming architecture. We encountered unsupported operations on Streaming Tables, pipeline failures caused by Delta transaction history, checkpoint behavior that prevented recovery even after the original code had been removed, and operational constraints that ultimately influenced the production solution.</p><p>Looking back, the most valuable lesson was not how to resolve a specific error message. It was understanding why the platform behaved exactly as it did.</p><h3>The Pipeline Architecture</h3><p>The pipeline followed a fairly typical streaming architecture built using Auto Loader and Lakeflow Declarative Pipelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*mQ108N4VNP0S9wh98fgh8w.png" /></figure><p>Auto Loader continuously ingested CSV files into raw Delta tables. These tables served as the landing layer and remained append-only throughout the ingestion process. Every new file produced additional Delta transactions that downstream streaming queries could process incrementally.</p><p>The raw layer then fed apply_changes(), which produced the final Streaming Tables consumed by reporting applications.</p><p>One detail that seemed relatively unimportant during implementation later became central to the investigation.</p><p>Several of the final Streaming Tables were themselves used as streaming sources for additional transformations within the same pipeline. Although these tables represented business-ready data, they were still active participants in the streaming workflow rather than being terminal reporting tables.</p><p>That distinction explained much of what followed.</p><h3>Investigation Timeline</h3><p>Looking back, the investigation progressed through a series of discoveries, each one leading naturally to the next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*nPAs5aNIrTY8KjP_lyfvpA.png" /></figure><p>At the time, each step felt like progress.</p><p>In hindsight, each new observation was simply exposing another assumption built into the streaming architecture.</p><h3>The First Assumption</h3><p>The business requirement was to remove records that had already reached the reporting layer.</p><p>The most obvious implementation was equally straightforward.</p><p>Delete those rows from the final Streaming Tables.</p><p>The notebook executed a standard SQL statement similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*a3Ecp5EKkxr059rsStZbeg.png" /></figure><p>The operation failed immediately with an error indicating that DELETE is not supported on a STREAMING_TABLE.</p><p>This behavior is expected.</p><p>Streaming Tables managed by Lakeflow Declarative Pipelines are owned by the pipeline that creates them. Unlike ordinary managed Delta tables, they are not intended to be modified through external DML operations such as DELETE, UPDATE, or INSERT. The pipeline owns both the table contents and the processing state associated with those tables.</p><p>At this point, the problem appeared relatively small.</p><p>The platform rejected one SQL statement.</p><p>Perhaps another statement could achieve the same business outcome.</p><h3>A MERGE That Appeared to Solve the Problem</h3><p>The next logical step was to replace the DELETE with a MERGE statement containing a WHEN MATCHED THEN DELETE clause.</p><p>Unlike the first attempt, the notebook completed successfully.</p><p>No SQL errors were reported.</p><p>No runtime exceptions occurred.</p><p>The target rows disappeared exactly as intended.</p><p>Everything suggested that the workaround had succeeded.</p><p>The next scheduled pipeline execution told a different story.</p><p>Instead of processing new data, the pipeline stopped with an error similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*H0LJ_QKVV45ZyP3w-Mirjw.png" /></figure><p>This was unexpected.</p><p>The MERGE had completed successfully.</p><p>The rows had been removed.</p><p>Why would the pipeline fail afterwards?</p><p>At this point we stopped looking at SQL syntax and started examining how the streaming engine actually processes data.</p><h3>Looking Beyond SQL</h3><p>Until this stage, every attempt focused on finding a SQL statement capable of removing records.</p><p>The assumption was that one command was unsupported while another might be acceptable.</p><p>The new error suggested something fundamentally different.</p><p>Streaming readers do not repeatedly scan the current contents of a Delta table.</p><p>Instead, they process the table’s transaction history incrementally.</p><p>Every write operation against a Delta table creates a new transaction in the Delta log.</p><p>For most streaming workloads, those transactions are expected to represent append-only changes.</p><p>A MERGE operation — even one whose only action is deleting rows — creates a transaction describing modifications to existing data rather than a simple append.</p><p>When one of the downstream streaming readers encountered that transaction, it detected that the history of its source table no longer matched the assumptions required for forward-only incremental processing.</p><p>The pipeline stopped.</p><p>The deleted rows themselves were never the problem.</p><p>The transaction history created by the MERGE was.</p><p>That realization fundamentally changed the direction of the investigation.</p><h3>The Failure Extended Beyond One Table</h3><p>The immediate pipeline failure was only part of the impact.</p><p>Because the pipeline terminated as soon as the first downstream streaming reader encountered the modified transaction history, every dependent workflow task was also prevented from executing.</p><p>Data validation did not run.</p><p>Reporting refreshes were skipped.</p><p>Other downstream processes waiting on successful pipeline completion never started.</p><p>What initially appeared to be a small maintenance operation had interrupted an entire production workflow.</p><p>At this stage, we still believed the issue was related to where we were performing the delete rather than how the pipeline interpreted those changes.</p><p>The next step was to examine the architecture itself and determine whether we had modified tables that should never have been touched.</p><h3>Re-examining the Architecture</h3><p>Initial conclusion was that the pipeline had failed because we modified the wrong tables.</p><p>The delete notebook originally executed against both the raw staging tables and the final Streaming Tables. Looking back, that decision deserved closer examination.</p><p>The raw staging layer is populated exclusively by Auto Loader. Its responsibility is to ingest incoming files exactly as they arrive and preserve an append-only history that downstream streaming readers can process incrementally. Those tables are not intended to be modified outside the ingestion process.</p><p>With that understanding, we removed every raw staging table from the delete operation and limited the notebook to modifying only the final Streaming Tables.</p><p>From an architectural perspective, this was unquestionably an improvement.</p><p>The pipeline still failed.</p><p>Initially, that result was difficult to explain. We had stopped modifying the ingestion layer, yet the error remained exactly the same.</p><p>The answer became clear only after tracing the lineage of every table within the pipeline.</p><p>Although the raw staging tables only fed apply_changes(), several of the final Streaming Tables also served as streaming sources for later transformations. They were not merely reporting tables. They were active participants in the streaming workflow.</p><p>Changing the location of the modification did not change the underlying problem.</p><p>We were still modifying tables whose transaction history was being consumed by downstream streaming readers.</p><h3>The Architectural Conflict</h3><p>At this point, the investigation shifted away from SQL entirely.</p><p>The external notebook and the streaming pipeline were operating under two different assumptions.</p><p>The notebook assumed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*4EO7uOSxG3Fnc3B9x8sEVg.png" /></figure><p>The streaming engine assumed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*eDF-lRxK8uPYYtRJFsnvJg.png" /></figure><p>Neither assumption was incorrect.</p><p>The conflict arose because they described the same tables from two different perspectives.</p><p>Looking back, this was the turning point of the investigation.</p><p>Until then, every attempt focused on finding another SQL statement.</p><p>From this point onward, the investigation focused on understanding the processing model of the streaming engine.</p><p>Once we understood that model, the previous failures became much easier to explain.</p><h3>Why Reverting the Notebook Didn’t Help</h3><p>After identifying the MERGE statement as the trigger, the obvious next step was to remove it.</p><p>The notebook was reverted.</p><p>The pipeline was restarted.</p><p>The exact same error appeared again.</p><p>Initially, this seemed contradictory. If the code responsible for creating the problem had already been removed, why was the pipeline still failing?</p><p>The answer lies in the role of streaming checkpoints.</p><p>A checkpoint stores the processing state of every streaming reader, including the Delta version that has already been processed. When the pipeline starts again, it does not begin reading from the beginning of the table. Instead, it resumes from the version recorded in the checkpoint.</p><p>Unfortunately, removing the notebook did not remove the Delta transaction that had already been committed.</p><p>That transaction was now part of the table’s history.</p><p>When the pipeline restarted, the checkpoint instructed the streaming reader to continue from exactly the same Delta version. The reader encountered the same non-append transaction, produced the same error, and stopped at exactly the same point.</p><p>Changing notebook code changes future executions.</p><p>It does not rewrite Delta transaction history that has already been committed.</p><p>This was another important lesson from the investigation.</p><h3>Investigating Pipeline Recovery</h3><p>At this stage, rebuilding the entire pipeline seemed unnecessary.</p><p>If the checkpoint was repeatedly directing the streaming reader to the same Delta version, perhaps deleting only the affected checkpoint would allow processing to continue.</p><p>The investigation therefore shifted toward locating the pipeline’s checkpoint storage.</p><p>Opening the pipeline configuration revealed another unexpected detail.</p><p>No external storage location had been configured.</p><p>The pipeline was using Databricks-managed storage for its internal state.</p><p>This meant the checkpoint information, materialization metadata, and other internal pipeline objects were managed entirely by the platform.</p><p>Although internal materialization tables created by the pipeline were visible, there was no supported mechanism to navigate to an underlying checkpoint directory and selectively remove only the affected state.</p><p>In this environment, the pipeline state was intentionally abstracted from direct filesystem access.</p><p>That realization ruled out another potential recovery option.</p><h3>Why Every Restart Produced the Same Result</h3><p>Once the checkpoint behavior became clear, every failed restart followed the same sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*_EpbUQ2CrngvUPbI1IJpWA.png" /></figure><p>Nothing in that sequence had changed.</p><p>The notebook had changed.</p><p>The Delta transaction history had not.</p><p>The checkpoint had not.</p><p>Consequently, every restart reproduced the same failure.</p><h3>Why Enabling skipChangeCommits Wasn&#39;t the End of the Investigation</h3><p>After identifying skipChangeCommits as the appropriate configuration, we expected the next pipeline execution to complete successfully.</p><p>Instead, the pipeline continued to fail.</p><p>This initially suggested that the configuration had not taken effect. However, further investigation showed that the issue was more complex than the original MERGE operation.</p><p>The pipeline contained multiple Streaming Tables, several of which were themselves consumed by downstream streaming transformations. Although enabling skipChangeCommits addressed the original streaming reader, additional downstream readers were still encountering the same non-append transaction as they processed the modified table.</p><p>In other words, the problem was no longer isolated to a single Streaming Table. The entire dependency chain needed to be evaluated to ensure every downstream streaming reader could successfully process the updated transaction history.</p><p>Although the root cause had now been identified, the pipeline was still not operational. The investigation had shifted from understanding <em>why</em> the pipeline failed to determining the safest way to recover it without introducing additional inconsistencies. That ultimately led us to the final stage of the investigation — a Full Refresh.</p><h3>Why a Full Refresh Became Necessary</h3><p>With the root cause understood and the pipeline configuration corrected, the remaining challenge was recovering the pipeline itself. At that stage, a Full Refresh became the most reliable recovery mechanism.</p><p>A Full Refresh resets the pipeline state, including its streaming checkpoints, and rebuilds the managed Streaming Tables from the pipeline’s configured source.</p><p>One important point is worth highlighting.</p><p>A Full Refresh is only effective if the configured source still contains enough historical data to recreate the required state. In some architectures, that source may be the original landing zone containing all historical files. In others, it may be a Bronze table or another retained source of truth.</p><p>If only recent incremental deliveries remain available, a Full Refresh cannot recreate historical data that no longer exists.</p><p>In this scenario , sufficient historical data was available, allowing the Full Refresh to successfully rebuild the pipeline.</p><p>The practical consequence, however, was significant.</p><p>Every unsuccessful experiment now required another Full Refresh before the next approach could be tested.</p><p>The debugging cycle became considerably longer than anticipated.</p><h3>What Fooled Us</h3><p>Looking back, one aspect of the investigation is worth calling out.</p><p>Every individual observation suggested we were making progress.</p><p>• DELETE was rejected, but that appeared to be a platform limitation.</p><p>• MERGE completed successfully.</p><p>• The rows disappeared.</p><p>• The notebook finished without error.</p><p>Each observation reinforced the belief that we had found a valid workaround.</p><p>None of those observations evaluated the one thing that actually mattered.</p><p>The health of the downstream streaming readers.</p><p>By focusing on the success of the SQL statement, we overlooked the transaction history that statement produced.</p><p>The pipeline was behaving exactly as designed.</p><p>We simply weren’t evaluating the correct layer of the system.</p><h3>The Production Solution</h3><p>By this point, it was clear that we needed an operational solution compatible with the existing architecture.</p><p>The solution consisted of two complementary changes.</p><p>The first was enabling the following pipeline configuration.</p><pre>{&quot;spark.databricks.delta.streaming.skipChangeCommits&quot;: &quot;true&quot;}</pre><p>This configuration instructs streaming readers to continue processing when they encounter externally generated non-append commits instead of terminating the pipeline.</p><p>It is important to understand what this configuration does.</p><p>It does not process those changes.</p><p>Instead, it allows the streaming reader to skip those externally generated change commits and continue processing newly appended data.</p><p>This distinction is important because it influences when the configuration should be used.</p><p>It is also worth noting that skipChangeCommits affects every streaming reader that inherits the pipeline configuration. Before enabling it, verify that none of the pipeline’s streaming queries rely on processing upstream updates or deletes as part of their normal logic. Pipelines that intentionally consume change events — for example through Change Data Feed — should evaluate this setting carefully before applying it globally.</p><p>The second change addressed workflow sequencing.</p><p>Originally, the delete notebook executed before the pipeline.</p><p>That guaranteed the next pipeline execution would immediately encounter externally modified Streaming Tables.</p><p>The workflow was reordered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*QBeoEQLwRjt_lEAg2GS_HQ.png" /></figure><p>Allowing the pipeline to complete first eliminated write conflicts during execution while still satisfying the business requirement.</p><p>Because the upstream system did not subsequently reintroduce those deleted records, the removals remained effective between pipeline runs.</p><p>This behavior, however, depends on the characteristics of the upstream source and should not be generalized to every streaming architecture.</p><h3>The Preferred Architectural Pattern</h3><p>Although the production workaround solved the operational problem, it is not the architecture I would choose when designing a new pipeline.</p><p>If delete events are available from the upstream system, the preferred approach is to process them inside the pipeline itself.</p><p>Conceptually, the implementation looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*ekfSwGRA4Dg7bbBhq_TrrA.png" /></figure><p>In this design, delete events become part of the streaming data rather than external table mutations.</p><p>The pipeline processes inserts, updates, and deletes within the same incremental execution model, eliminating the need to modify Streaming Tables outside the pipeline.</p><p>Whenever the upstream source supports this pattern, it is generally the cleaner architectural choice.</p><h3>Lessons Learned</h3><p>• Streaming readers process Delta transaction history, not simply table contents.</p><p>• A SQL statement that executes successfully can still generate transaction history that downstream streaming readers cannot process.</p><p>• Reverting notebook code changes future executions but does not remove transactions that have already been committed to the Delta log.</p><p>• Streaming checkpoints resume processing from previously recorded Delta versions. Unless the pipeline state is reset or the transaction history changes, the same failure will continue to occur.</p><p>• Raw Auto Loader tables should remain append-only and should not be modified externally.</p><p>• Even final Streaming Tables require careful consideration if they are consumed by downstream streaming queries.</p><p>• There is an important distinction between a production workaround and a preferred architecture: skipChangeCommits combined with workflow sequencing resolved the operational issue, but modeling delete events inside the pipeline using apply_changes(…, apply_as_deletes=…) remains the cleaner long-term design whenever the upstream data supports it.</p><h3>Conclusion</h3><p>Production incidents are often remembered because of the error messages they generate.</p><p>In reality, those error messages are usually the final symptom rather than the root cause.</p><p>The SQL statements in this investigation behaved exactly as they were designed to.</p><p>DELETE was rejected because Streaming Tables are owned by the pipeline.</p><p>MERGE succeeded because it was a valid Delta operation.</p><p>The downstream streaming readers stopped because they encountered transaction history that no longer matched the assumptions required for incremental processing.</p><p>None of these components behaved incorrectly.</p><p>The failure occurred because different parts of the platform made different assumptions about the same tables.</p><p>Once those assumptions became clear, the platform’s behavior was no longer surprising.</p><p>The solution was not finding another SQL statement.</p><p>It was understanding the architectural boundaries of the streaming engine and designing the implementation to respect those boundaries.</p><p>That lesson extends well beyond this particular incident.</p><p>Whether working with streaming pipelines, distributed processing frameworks, or transactional storage systems, many production issues arise not because individual components fail, but because the interactions between those components violate assumptions that were never explicitly documented.</p><p>Understanding those assumptions is ultimately what transforms troubleshooting from trial and error into engineering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0624c5464e2f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/why-a-successful-merge-broke-our-databricks-streaming-pipeline-0624c5464e2f">Why a Successful MERGE Broke a Databricks Streaming Pipeline</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI SQL Sentinel: A Database Performance Monitoring Tool Built on Operational Knowledge]]></title>
            <link>https://pub.towardsai.net/ai-sql-sentinel-a-database-performance-monitoring-tool-built-on-operational-knowledge-4248cf7f0c9c?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/4248cf7f0c9c</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 21:01:00 GMT</pubDate>
            <atom:updated>2026-07-04T13:28:36.111Z</atom:updated>
            <content:encoded><![CDATA[<p>Most database monitoring tools tell you something is wrong. The harder problem is explaining what is wrong, why it happened, and what to do about it — quickly enough to matter.</p><p>AI SQL Sentinel is a performance monitoring system for SQL Server and PostgreSQL that automates that diagnostic step. It collects live database evidence, identifies known failure patterns, retrieves matching expert guidance, and produces a structured diagnosis with a root cause, a confidence score, and executable resolution steps. The investigation that would otherwise take 20 to 40 minutes of manual querying happens in under a minute.</p><p>This article describes what the tool does, how it is structured, and the design decisions behind it.</p><h3>What It Produces</h3><p>Before describing the architecture, here is the actual output from a live run against a CDC log pressure incident:</p><pre>Type:  cdc_log_pressure     Job:  CDC_LOG_SCAN</pre><pre>Root Cause:  CDC scan session stuck for 420s with 0 commands processed.<br>             Transaction log held open — WRITELOG cascading to all concurrent DML.<br>Confidence:  87%</pre><pre>Evidence:<br>  • scan_status=STUCK_ACTIVE, duration=420s, command_count=0<br>  • avg_write_ms=18.3 on OpsInsights (threshold: 5ms)<br>  • WRITELOG waits on 4 concurrent sessions during job window</pre><pre>Recommended Actions:<br>  1. EXEC sys.sp_cdc_stop_job &#39;capture&#39;; EXEC sys.sp_cdc_start_job &#39;capture&#39;;<br>  2. Tune sp_cdc_change_job @maxtrans=2000, @maxscans=20<br>  3. Verify log disk throughput — avg_write_ms &gt; 10ms indicates disk saturation</pre><pre>Recurring: seen 3 times in last 30 days  |  Blocking co-fired 2 of 3 times</pre><p>Root cause is evidence-based, not generic. Confidence reflects actual certainty. Evidence cites measured values from the database. Recommended actions are specific, executable SQL. The recurring pattern and co-occurrence note come from stored incident history, not from inference.</p><h3>Why Traditional Monitoring Wasn’t Enough</h3><p>Traditional monitoring platforms excel at collecting metrics and generating alerts. They are intentionally conservative about drawing conclusions because diagnosing root cause requires context, history, and operational judgment that a generic alerting system cannot reliably supply.</p><p>The result is a consistent pattern: the alert fires, a DBA connects, and the manual investigation begins — checking wait stats, examining blocking chains, reviewing execution plans, correlating timing across subsystems. The monitoring tool told you something was wrong. It did not tell you why. That investigation takes 20 to 40 minutes for a familiar failure pattern and longer for anything unusual.</p><p>AI SQL Sentinel focuses on that diagnostic layer. Rather than asking an operator to manually correlate evidence, it attempts to assemble the evidence, retrieve relevant operational knowledge, and produce a structured diagnosis before a human begins the investigation. The monitoring alert becomes the starting point of a resolved incident rather than the starting point of a manual search.</p><p>The distinction is not that traditional tools are inadequate — it is that they were designed for a different job. Metric collection and alerting are solved problems. Automated diagnosis from live evidence is not.</p><h3>How It Works — Six Stages</h3><p>Every run works through the same six stages in sequence, fully automatic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXX7KOMXTG2Zso3odDURoA.png" /></figure><blockquote><strong><em>Database Evidence → Expert Reasoning → Actionable Diagnosis</em></strong></blockquote><p><strong>1 · Collect</strong> — Gathers evidence without touching the monitored database.</p><p><strong>2 · Detect</strong> — Identifies which failure patterns are active.</p><p><strong>3 · Suppress</strong> — Filters noise before any AI call is made.</p><p><strong>4 · Retrieve</strong> — Finds the most relevant expert guide from the knowledge base.</p><p><strong>5 · Explain</strong> — Combines the evidence and guide into a structured diagnosis.</p><p><strong>6 · Learn</strong> — Stores the outcome so future incidents on the same target have more context.</p><h3>Architecture: Three Databases, Two Processes</h3><p>The system uses three distinct database connections, each with a different role.</p><p><strong>Monitored SQL Server</strong> — evidence source only. The tool reads sys.dm_exec_requests, ring buffers, Query Store, job history from msdb, and related system views. It never writes to the monitored server. The login requires VIEW SERVER STATE and SQLAgentReaderRole in msdb — no elevated permissions, no schema changes.</p><p><strong>Monitored PostgreSQL</strong> — evidence source only, read via pg_monitor role. The tool reads pg_stat_activity, pg_stat_bgwriter, pg_replication_slots, pg_class, and related catalog views.</p><p><strong>PostgreSQL repository on Neon</strong> — the only database the tool writes to. All persistent storage lives here: incidents, alert quality records, job history ingested from SQL Server, 5-minute snapshots, and the runbook knowledge base with vector embeddings.</p><p>Two processes run on a schedule:</p><p>collect_snapshots.py runs every five minutes. It photographs the current state of the monitored database — blocking chains, deadlock events, memory queues, CPU ring buffer, CDC scan state, replication lag — and writes everything to the Neon repository. This enables historical replay and pattern learning.</p><p>detect_issues.py runs on demand or on a schedule. It reads those snapshots or queries live views directly, runs all detectors, calls the AI model, and stores validated diagnoses. It can run against today&#39;s live data or replay any historical date using the --date flag.</p><h3>The Detection Layer: 25 Failure Patterns</h3><p>Every detector query fires only when a threshold is crossed. Zero rows returned means nothing to investigate. The AI is never called on normal activity.</p><h3>SQL Server — 13 detectors</h3><p><strong>Job baseline comparison</strong> checks each job’s last 24 hours against its 30-day P50 median. It requires at least 10 baseline runs for statistical stability and fires when a job runs more than twice its normal time.</p><p><strong>Job trend detection</strong> uses linear regression on 14 days of run history to surface slow-burn deterioration before it crosses the 2× threshold. It fires when the trend is clearly upward but the job has not yet doubled — an early warning that arrives 2 to 5 days before the condition becomes an incident.</p><p><strong>Live blocking</strong> checks for active lock waits and blocked sessions in the current DMV snapshot.</p><p><strong>Deadlock detection</strong> parses the SQL Server system health extended events ring buffer for deadlock events in the last two hours. The ring buffer holds approximately 256 events and resets on server restart. The snapshot table in the repository provides durable storage that survives restarts.</p><p><strong>Memory pressure</strong> fires when sessions are queuing for memory grants (RESOURCE_SEMAPHORE wait type) or server RAM exceeds 92%.</p><p><strong>CPU pressure</strong> fires when average SQL Server CPU exceeds 80% across ring buffer samples. The AI prompt contains an explicit diagnostic rule for this: low CPU time combined with high elapsed time is memory starvation, not CPU saturation — a distinction that changes the fix path entirely.</p><p><strong>CDC log scan pressure</strong> checks CDC scan sessions for the stuck state — open more than five minutes with zero commands processed. Also monitors log write latency above 5ms. Completely silent on instances without CDC enabled.</p><p><strong>Long-running execution with severity scoring</strong> scores each active session on 11 compounding signals: elapsed time, being blocked by another session, blocking other sessions, holding an open transaction, critical wait types, high logical reads, write pressure, and CPU time. A backup running alone scores 1 and is ignored. A session running 87 minutes while blocking three others and holding an open transaction scores 9 and fires immediately. Multiple concurrent risk signals are required before a high-severity alert fires.</p><p><strong>Query intelligence</strong> watches for seven structural query problems: missing indexes with cardinality analysis, plan instability across Query Store executions, top resource-consuming queries by logical reads, unused high-cost indexes on write-heavy tables, stale statistics, implicit type conversions forcing table scans, and sampled statistics quality anomalies. The last signal fires when statistics were recently updated but the sample rate was too low to accurately represent the value distribution — auto-update alone does not fix it, and the resolution path differs from stale statistics.</p><p><strong>tempdb pressure</strong> watches four distinct failure modes: session spills over 500MB, version store growth over 10GB, allocation page contention from too few tempdb data files, and file capacity approaching 85%. Each has a different fix. All four cause every query to slow simultaneously with moderate CPU and no blocking — a signature that no other detector catches.</p><p><strong>Storage I/O saturation</strong> fires when data file read or write stall exceeds 20ms per IO, or when five or more sessions are waiting for pages to load from disk simultaneously.</p><p><strong>Hot page latch contention</strong> fires when three or more threads compete simultaneously for an exclusive in-memory page latch on the same user database B-tree page — the pattern caused by clustered indexes with sequentially increasing keys. The fix is at the schema level.</p><p><strong>Worker thread starvation</strong> requires two signals simultaneously: live tasks queued with no worker thread assigned, and non-zero work queue counts on online schedulers. Neither alone is sufficient. Both together confirms the server is failing to hand out workers — new requests queue, SQL Agent jobs fail to start, logins may time out. This condition can develop and cause an outage in 60 to 90 seconds. A session-duration detector with a 30-minute threshold would never catch it.</p><h3>PostgreSQL — 12 detectors</h3><p>The PostgreSQL path covers blocking via pg_blocking_pids(), deadlocks, memory pressure via bgwriter statistics, CPU via active session patterns, WAL replication lag including inactive slots retaining WAL on disk, long-running sessions, query performance via pg_stat_statements, I/O pressure via cache miss rate, table bloat from dead tuple accumulation, vacuum lag and XID wraparound risk, and a three-signal visibility horizon blocker for stale replication slot xmin, forgotten prepared transactions, and MultiXact ID exhaustion.</p><h3>Suppression: Keeping the Signal Clean</h3><p>Four rules run before the AI is called, ensuring the AI only runs on issues that are real, new, and worth investigating.</p><p><strong>Maintenance window</strong> — if a configured maintenance window is active, non-critical alerts are suppressed silently. The window is set in the environment file and supports midnight-crossing ranges.</p><p><strong>Known workload exceptions</strong> — jobs listed as expected-slow are permanently skipped. Nightly index rebuilds, end-of-month archival jobs, and similar predictable long-running work do not generate alerts.</p><p><strong>Duplicate Alert Prevention</strong>— if the same issue type fired for the same job in the last four hours, it is suppressed. The same active problem does not flood the team.</p><p><strong>Severity threshold</strong> — for the long-running session detector, only sessions scoring 3 or above proceed. Low-scoring sessions are logged to the alert quality table but do not reach the AI.</p><p>Eight issue types bypass all four rules regardless: deadlocks, memory pressure, CPU pressure, tempdb pressure, I/O saturation, hot page latch contention, worker thread starvation, and the PostgreSQL visibility horizon blocker. Active failure conditions that can cause immediate data loss or outage are never suppressed.</p><p>Every suppression decision is written to the alert quality table with its reason. The team can always query what was seen, what score it received, and why it was held back.</p><h3>Runbook Retrieval: Finding the Right Expert Guide</h3><p>Before the AI sees any evidence, it retrieves the most relevant troubleshooting guide from the knowledge base. The retrieval uses two gates.</p><p><strong>Hard category filter first.</strong> Each detector produces a fixed issue type string that maps to a runbook category. A SQL query restricts the search to only that category. A tempdb runbook cannot compete against a blocking runbook regardless of vocabulary. The category is determined by the detector, not by text similarity.</p><p><strong>Semantic similarity search second.</strong> Within the filtered category, the issue description is encoded into a 384-dimensional vector using all-MiniLM-L6-v2 and compared against pre-computed runbook embeddings using cosine distance via pgvector. Results below a 0.40 similarity score are dropped — an irrelevant runbook is worse than no runbook.</p><p>The knowledge base contains 37 runbooks — 27 for SQL Server, 10 for PostgreSQL. Each contains four sections: a signal fingerprint written to match the vocabulary the detector produces, ranked root cause paths ordered by likelihood, investigation and resolution steps from least invasive to most disruptive, and an explicit section on what not to do. The wrong-path section exists because an AI model given plausible evidence will sometimes recommend the wrong fix confidently. Encoding the wrong answers prevents that.</p><p>The runbooks cover every detector type — job slowdown triage, blocking and lock contention, uncommitted transaction blocking, ETL and read contention, all seven query intelligence signals, hot page latch contention, storage I/O saturation, worker thread starvation, plan regression, parameter sniffing, deadlock resolution, memory grant pressure, CPU saturation, CDC log scan lag, long-running session triage, tempdb pressure, and the full PostgreSQL coverage including visibility horizon blockers, table bloat, vacuum lag, WAL replication lag, memory and CPU pressure, query intelligence, I/O saturation, and temporary space pressure.</p><h3>The AI Prompt: Nine Sections</h3><p>The prompt the AI receives is assembled from nine sections, each with a specific job.</p><p><strong>Section 1</strong> assigns the engine-specific persona — SQL Server DBA or PostgreSQL DBA. The PostgreSQL persona contains an explicit prohibition against suggesting SQL Server tools. Without this, the model will occasionally suggest SQL Server-specific commands for PostgreSQL incidents.</p><p><strong>Section 2</strong> provides a ten-step reasoning framework the AI must work through in sequence: what changed, is blocking present and when did it start, is memory or CPU the constraint, is CDC holding the log, is another database consuming disproportionate resources, is a plan regression visible, is the pattern time-of-day related, what is the safest first action.</p><p><strong>Section 3</strong> provides the incident summary — issue type, job name, current and baseline values.</p><p><strong>Section 4</strong> handles temporal validation. Suspected causes must have occurred during the incident window. This prevents a specific wrong diagnosis: a job ran slow, a blocking chain appeared in a snapshot taken after the job completed, and the AI attributes the slowdown to that blocking. With the temporal rule, the AI identifies it as coincident, not causal.</p><p><strong>Section 5</strong> provides query regression detail from Query Store when available — plan IDs before and after, plan count, execution counts.</p><p><strong>Section 6</strong> provides blocking evidence sanitised and capped at eight sessions, with cross-database blocking explicitly flagged.</p><p><strong>Section 7</strong> provides resource pressure evidence formatted specifically for the issue type that fired. The format for a tempdb incident differs from the format for a memory pressure incident.</p><p><strong>Section 8</strong> provides server-level context — which database is consuming the most CPU, reads, and log write latency, with the monitored job’s database marked.</p><p><strong>Section 9</strong> injects the retrieved runbook with its similarity score visible to the model. The score signals how heavily to weight the retrieved guidance versus the model’s own evidence reasoning.</p><p>Historical patterns from stored incidents are also included: whether this issue has recurred in the last 30 days, whether it follows a time-of-day pattern, and which other issue types have co-fired alongside it in past incidents. If blocking has co-fired with deadlocks in 80% of past incidents on this target, the AI is told explicitly and this is treated as a strong signal when forming the root cause.</p><p>The output is structured JSON — root cause, confidence score as a float between 0 and 1, evidence array citing observed values only, and ranked recommended actions. Schema validation runs before anything is stored. Malformed responses produce a safe fallback rather than a lost incident.</p><h3>Security</h3><p>Sanitisation is hardcoded on and cannot be disabled. Login names are hashed with SHA-256. Hostnames are replaced entirely. SQL text is truncated at the database level before it leaves the server — enough to identify the operation, not enough to expose literal values from WHERE clauses. Deadlock query text is capped at 80 characters.</p><p>Five authentication modes are supported for SQL Server: standard SQL login, Windows integrated authentication, Azure Managed Identity, Azure AD password, and Kerberos. In cloud and domain-joined environments the SQL login credential can be eliminated entirely.</p><p>The monitored SQL Server login requires VIEW SERVER STATE and SQLAgentReaderRole in msdb. No sysadmin. No write access. No schema creation on monitored systems.</p><h3>Alert Quality Measurement</h3><p>The system measures its own quality. The alert quality table records every firing decision and every suppression with its reason. Operators can label incidents as true positive, false positive, or noise using a CLI command.</p><pre>python detect_issues.py --quality-report</pre><p>The report shows suppression rate, mean AI confidence per issue type, detector activity over the selected period, repeat offenders, and precision once enough operator feedback has been recorded.</p><h3>Current State</h3><p>The system has been validated against reproduced failure scenarios — real patterns recreated using sample databases in a controlled environment. It has not yet been deployed against a live production database.</p><p>What has been built: 25 detectors, 37 runbooks, 532 unit tests requiring zero database connections, read-only access throughout, no agents, no writes to monitored systems, configurable AI provider (Anthropic Claude or OpenAI, switched via a single environment variable).</p><p>What comes next: a production pilot to measure detection accuracy and diagnostic quality against real workloads, and integration with Slack and email notification so incidents reach the team without requiring manual polling.</p><h3>Limitations and Open Questions</h3><p>The system has been validated against reproduced failure scenarios, but several areas remain intentionally unmeasured until a production pilot is completed.</p><p><strong>False positive rate</strong> is not yet available because no production incident data exists. The alert quality framework and operator feedback workflow have been implemented to measure this during the pilot.</p><p><strong>Runbook retrieval accuracy</strong> has been validated during development through category-gated retrieval and similarity thresholds, but has not yet been benchmarked against a representative production dataset.</p><p><strong>Runbook maintenance and drift</strong> remain a human-reviewed process. Incident history and AI diagnoses are retained to support future refinement, but no automated drift detection currently exists.</p><p><strong>Detector maintenance</strong> is intentionally lightweight, with thresholds externalised from detection logic, though future platform and DMV changes may require periodic updates.</p><p><strong>AI and runbook disagreements</strong> are preserved for review rather than automatically overridden. The runbook serves as guidance, while the final diagnosis remains evidence-driven.</p><p>The production pilot will focus on answering these questions with real operational data.</p><p>The tool does one thing: when a database issue occurs, it produces a diagnosis — root cause, evidence, confidence, and specific actions — before a DBA has had time to open a query window. How much of the subsequent investigation that eliminates depends on what the pilot reveals.</p><p><em>Technical reference: the complete detector query documentation, DMV and system view matrix, prompt structure, JSON output schema, and runbook content are documented separately in the project repository.</em></p><h3>Open Source Repository</h3><p>If you’d like to explore the implementation in more detail, <strong>AI SQL Sentinel</strong> is available as an open-source project on GitHub:</p><p><strong>GitHub Repository:</strong> <a href="https://github.com/rathinamb/balur/tree/main/ai_sql_sentinel">https://github.com/rathinamb/balur/tree/main/ai_sql_sentinel</a></p><p>The repository contains the current reference implementation, supporting database scripts, documentation, and sample configurations developed and evaluated in a controlled environment. It is intended to complement the architectural concepts discussed in this article and will continue to evolve as the project progresses through future validation and production pilot activities.</p><p>Feedback, feature suggestions, bug reports, and contributions are always welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4248cf7f0c9c" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/ai-sql-sentinel-a-database-performance-monitoring-tool-built-on-operational-knowledge-4248cf7f0c9c">AI SQL Sentinel: A Database Performance Monitoring Tool Built on Operational Knowledge</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When PAGE Compression Quietly Kills Your Write Performance]]></title>
            <link>https://medium.com/towards-data-engineering/when-page-compression-quietly-kills-your-write-performance-243a879f985e?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/243a879f985e</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[performance-tuning]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 05:25:30 GMT</pubDate>
            <atom:updated>2026-07-19T21:48:27.627Z</atom:updated>
            <content:encoded><![CDATA[<p>How a seemingly harmless storage optimization created a 3× regression in an ETL validation workload.</p><h3>The Setup</h3><p>ETL pipelines tend to accumulate complexity over time. Ours was no exception.</p><p>Incoming data moved through a validation phase before being merged into standardized history tables. As the dataset grew, so did the operational friction: updates were blocking reads, schema changes required table-level locks, and maintenance windows were creeping longer.</p><p>The fix seemed straightforward. We introduced <strong>table partitioning</strong> on the history table and added a <strong>staging table</strong> so that updates could happen in isolation before a partition switch made the data live. Partition switches in SQL Server are metadata operations — nearly instantaneous — so this design looked like a clean win on all fronts.</p><p>Then the regressions appeared.</p><h3>The Symptom: 3× Slower on One-Tenth the Data</h3><p>Validation steps that previously ran in ~15 minutes were now taking ~45 minutes. That alone was alarming. What made it <em>puzzling</em> was a specific data point that defied intuition:</p><blockquote><em>A single </em><em>UPDATE statement that ran in </em><strong><em>~2 seconds</em></strong><em> against the full history table now took </em><strong><em>~9 seconds</em></strong><em> against the staging table — a dataset nearly </em><strong><em>one-tenth the size</em></strong><em>.</em></blockquote><p>This breaks every instinct you develop as a data engineer. More rows should mean more time. Fewer rows should mean less time. The inversion was the signal that something structural — not logical — had changed.</p><h3>The Investigation: Ruling Out the Obvious</h3><p>Before chasing the real cause, the usual suspects were addressed:</p><ul><li><strong>Unnecessary joins</strong> were removed — staging isolation made several of them redundant</li><li><strong>Redundant </strong><strong>GROUP BY clauses</strong> were eliminated where uniqueness was already guaranteed</li><li><strong>Excessive iteration</strong> in batching logic was reduced — earlier batching had caused repeated passes over the same dataset</li></ul><p>These were genuine improvements. Validation time dropped from ~45 minutes to ~28 minutes.</p><p>But 28 minutes is still almost double the original 15. And the 9-second UPDATE on a a small table remained unexplained.</p><p>At this point, query optimization had hit its ceiling. The problem wasn’t in the SQL.</p><h3>The Root Cause: PAGE Compression and the Hidden Write Tax</h3><p>With query-level explanations exhausted, the investigation moved to <strong>physical storage characteristics</strong> — specifically, how the new tables were created.</p><p>The partitioned history and staging tables had been built with <strong>PAGE compression</strong> on their clustered indexes. The original table had none.</p><p>This single difference explained everything.</p><h3>How PAGE Compression Works (and Why It Hurts Writes)</h3><p>PAGE compression in SQL Server uses a combination of techniques — row compression, prefix compression, and dictionary compression — to maximize how many rows fit on an 8KB data page. It’s genuinely effective: storage savings of 40–80% are common on repetitive data, and read performance often improves because fewer pages need to be pulled from disk or buffer pool.</p><p>But compression is not free for writes. Every UPDATE to a row on a compressed page triggers this cycle:</p><pre>Read page from buffer pool<br>  → Decompress entire page<br>    → Modify the target row(s)<br>      → Recompress entire page<br>        → Write page back</pre><p>This isn’t a small overhead. It’s a full decompression and recompression of the entire 8KB page — for every page that contains a row touched by your update. When an UPDATE statement touches thousands of rows spread across hundreds of pages, this cycle repeats hundreds of times.</p><h3>Why the Smaller Table Was Slower</h3><p>The original uncompressed table was larger on disk, but the per-row modification cost was minimal — read the page, flip the bytes, done.</p><p>The compressed staging table held far fewer rows, but every write carried the decompression/recompression penalty. At scale, that overhead dominated everything else.</p><h3>Operational Considerations Before Removing Compression</h3><p>Removing PAGE compression is not a metadata-only operation. When SQL Server executes:</p><pre>ALTER INDEX ...<br>REBUILD WITH (DATA_COMPRESSION = NONE);</pre><p>it rebuilds the index into a new uncompressed structure rather than modifying the existing pages in place. During this process, SQL Server may temporarily require storage for:</p><ul><li>The existing compressed index</li><li>The newly rebuilt uncompressed index</li><li>Transaction log generated by the rebuild</li><li>Sort operations (in the user database or tempdb, depending on the rebuild options)</li><li>Concurrent user workload executing against the database</li></ul><p>As a result, the storage required during the rebuild can be significantly higher than the final size of the uncompressed table. On very large tables, this temporary capacity requirement can become the limiting factor rather than the rebuild itself.</p><p>For this reason, changing data compression should be treated as both a <strong>performance optimization</strong> and a <strong>capacity planning exercise</strong>. Before executing the rebuild in production, validate the following:</p><ul><li>Estimate the expected increase in table size using sp_estimate_data_compression_savings.</li><li>Verify that sufficient free space exists in the data files for the larger uncompressed indexes.</li><li>Confirm that the transaction log has adequate capacity and that log truncation is not being delayed by long-running transactions, replication, CDC, or other log reuse waits.</li><li>Review available storage at the operating system or cloud volume level, not just within the database files.</li><li>For large partitioned or multi-terabyte tables, consider rebuilding one index or partition at a time instead of issuing a broad ALTER INDEX ALL operation.</li></ul><p>The objective is not simply to restore write performance — it is to ensure that the transition from compressed to uncompressed storage can complete safely without introducing avoidable storage pressure during the maintenance window.</p><h3>The Fix and Validation</h3><p>PAGE compression was removed from the clustered indexes on both the staging and history tables.</p><pre>ALTER INDEX [IX_History_Clustered] ON [dbo].[History]<br>REBUILD WITH (DATA_COMPRESSION = NONE);</pre><pre>ALTER INDEX [IX_Staging_Clustered] ON [dbo].[Staging]<br>REBUILD WITH (DATA_COMPRESSION = NONE);</pre><p>Results were immediate:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*OP3nveI1wog8vDfdKHEKlA.png" /></figure><p>The performance was fully restored. The partitioning design itself was sound — the problem was a single configuration decision made during table creation.</p><h3>What This Actually Teaches Us</h3><h3>1. Physical storage behavior is often the hidden variable in write performance</h3><p>Query plans, index statistics, and row counts explain a lot. But when those all look reasonable and performance still degrades, the answer is often in how data is physically stored and accessed.</p><h3>2. PAGE compression is a read optimization, not a universal one</h3><p>Compression shines in data warehousing and reporting workloads — heavy scans, low write frequency. In ETL pipelines with write-heavy validation steps, it can easily become the bottleneck. ROW compression is often a better trade-off in mixed workloads: moderate storage savings with significantly lower write overhead.</p><h3>3. Partitioning improves manageability — it doesn’t change write semantics</h3><p>Partition switching is fast. But the pages within each partition still obey the same physical rules. Partitioning is not a write performance feature; it’s an isolation and maintenance feature.</p><h3>4. Batching manages concurrency — it doesn’t reduce total work</h3><p>Batching is often misunderstood as a way to “do less.” It’s actually a way to spread the same work across time to avoid lock contention and log pressure. The total I/O is unchanged.</p><h3>5. Features don’t exist in isolation — workloads do</h3><p>PAGE compression, partitioning, batching — each is defensible on its own merits. The failure mode here wasn’t any single decision; it was applying a feature designed for read-heavy workloads to a write-heavy one, without modeling the interaction.</p><h3>The Summary Diagnostic Framework</h3><p>If you see an UPDATE running slower on a smaller dataset, work through this checklist before touching the query:</p><ol><li><strong>Check compression settings</strong> on the target table and its indexes</li><li><strong>Check page density and fragmentation</strong></li><li><strong>Check whether statistics are stale</strong></li><li><strong>Check for implicit conversions in predicates</strong></li><li><strong>Then look at query structure</strong></li></ol><p>In most cases, the query isn’t the problem. The table is.</p><p><em>The best-performing systems aren’t the ones using the most powerful features. They’re the ones using the right features for the right workload.</em></p><h3>Note</h3><p>All scenarios described are generalized engineering patterns derived from real-world experience. No proprietary system details, client data, or confidential information are included.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=243a879f985e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/when-page-compression-quietly-kills-your-write-performance-243a879f985e">When PAGE Compression Quietly Kills Your Write Performance</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scalable Transitive Matching Without Recursive CTEs]]></title>
            <link>https://medium.com/towards-data-engineering/scalable-transitive-matching-without-recursive-ctes-46dfeef9bc0c?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/46dfeef9bc0c</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[database-performance]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 21:59:30 GMT</pubDate>
            <atom:updated>2026-02-04T09:31:13.968Z</atom:updated>
            <content:encoded><![CDATA[<h3>Purpose</h3><p>In many data pipelines, records are not compared directly to each other. Instead, they are evaluated against a set of matching rules that capture identity, similarity, or business-defined equivalence. Each rule produces evidence — this record satisfies this condition — rather than a final grouping.</p><p>That distinction matters. As rule sets grow and datasets scale, the challenge shifts from <em>detecting individual matches</em> to <em>resolving all the transitive connections those matches imply</em>. This article walks through how that problem emerges, why recursive SQL approaches break down at scale, and how reframing the solution as a graph problem leads to a more predictable and scalable design.</p><p>The immediate result of this process is not a final grouping, but evidence of matches, capturing which records satisfied which rules rather than how records ultimately relate to one another:</p><ul><li><em>Record X satisfied Rule A</em></li><li><em>Record Y satisfied Rule A</em></li><li><em>Record Y satisfied Rule B</em></li><li><em>Record Z satisfied Rule B</em></li></ul><p>The challenge is to convert this evidence into <strong>stable, transitive groups</strong> — so that all records connected through any chain of rules are treated as belonging together.</p><h3>What the input data represents</h3><p>The raw output of the rule engine is captured in a table shaped like:</p><pre>-- Each row represents &quot;this record matched this rule&quot;<br>CREATE TABLE RuleRowMatch<br>(<br>    RowNumber     INT,<br>    MatchRuleId   INT<br>);</pre><h3>What this means logically</h3><p>This table does not describe direct row-to-row matches. Instead, it records rule evaluations: a given row satisfied a given rule. Two rows become related only when they share a rule, and those relationships are inherently transitive. If one rule links Row 1 to Row 2, and another rule links Row 2 to Row 3, then all three rows belong to the same group — even if Row 1 and Row 3 never matched under a single rule. At that point, the problem is no longer about individual rules or comparisons; it is about resolving connectivity across a growing set of relationships, which is fundamentally a graph problem.</p><h3>The real goal</h3><p>The real goal is to resolve transitive matching: identifying all records that are connected through any chain of rule evaluations and treating them as a single group. Each record becomes a node in this model, and a shared rule introduces a connection between nodes — an edge — indicating that those records were linked by at least one matching condition. As more rules are evaluated, these edges form chains of relationships, and the task becomes determining which nodes are reachable from one another through those chains. In practice, this means identifying connected sets of records within the resulting network of rule-based relationships.</p><h3>The original approach: recursive CTE</h3><p>Initially, this problem was solved using a <strong>recursive CTE</strong> that repeatedly expanded match relationships.</p><h3>Representative recursive CTE pattern</h3><pre>-- Step 1: Build direct row-to-row links from shared rules<br>WITH DirectLinks AS (<br>    SELECT r1.RowNumber AS Src, r2.RowNumber AS Dst<br>    FROM RuleRowMatch r1<br>    JOIN RuleRowMatch r2<br>        ON r1.MatchRuleId = r2.MatchRuleId<br>       AND r1.RowNumber &lt;&gt; r2.RowNumber<br>),</pre><pre>-- Step 2: Recursively walk the graph<br>RecursiveWalk AS (<br>    SELECT Src, Dst<br>    FROM DirectLinks</pre><pre>    UNION ALL</pre><pre>    SELECT w.Src, l.Dst<br>    FROM RecursiveWalk w<br>    JOIN DirectLinks l<br>        ON l.Src = w.Dst<br>)<br>SELECT DISTINCT Src, Dst<br>FROM RecursiveWalk<br>OPTION (MAXRECURSION 0);</pre><h3>Why this worked initially</h3><p>This approach worked well at first because it closely mirrored how the problem was understood. Starting from a record and repeatedly following its connections until no new relationships appeared was easy to reason about and aligned naturally with the idea of transitive matching. On smaller datasets, the recursive expansion stayed manageable, and the performance was acceptable enough that the solution felt both correct and practical.</p><h3>What changed as data grew (the problem)</h3><p>As data volume increased, several issues surfaced:</p><ol><li><strong>Explosive traversal cost</strong><br> Recursive expansion repeatedly explores overlapping paths, especially in dense match graphs.</li><li><strong>Heavy deduplication pressure</strong><br> DISTINCTs, anti-joins, and visited tracking become increasingly expensive.</li><li><strong>Unpredictable runtime</strong><br> Performance depends heavily on graph shape, not just row count.</li><li><strong>Optimizer limitations</strong><br> Recursive CTEs offer limited tuning control and often spill to tempdb under load.</li></ol><p>At scale, the recursive approach became the bottleneck — not because recursion is “wrong,” but because it does not degrade gracefully for large, interconnected graphs.</p><h3>Rethinking the solution</h3><p>Rethinking the solution required stepping back from repeatedly traversing relationships and instead focusing on making those relationships explicit. Rather than walking the graph over and over, the approach shifts to building the graph once and allowing connectivity to emerge through convergence. This reframing naturally leads to a two-phase design: first, constructing a clear representation of how records are connected, and second, resolving transitive relationships by iteratively propagating those connections until the system reaches a stable state.</p><h3>Phase 1: Build the graph explicitly (edges)</h3><h3>Convert rule matches into row-to-row edges</h3><pre>-- Create row-to-row pairs for records sharing a rule<br>CREATE TABLE RowMatchPairs<br>(<br>    RowA INT,<br>    RowB INT<br>);</pre><pre>INSERT INTO RowMatchPairs (RowA, RowB)<br>SELECT r1.RowNumber, r2.RowNumber<br>FROM RuleRowMatch r1<br>JOIN RuleRowMatch r2<br>    ON r1.MatchRuleId = r2.MatchRuleId<br>   AND r1.RowNumber &lt; r2.RowNumber;</pre><p>Each pair represents a <strong>direct connection</strong>.</p><h3>Make edges bidirectional</h3><pre>CREATE TABLE Edges<br>(<br>    FromRow INT,<br>    ToRow   INT<br>);</pre><pre>-- Original direction<br>INSERT INTO Edges<br>SELECT RowA, RowB FROM RowMatchPairs;</pre><pre>-- Reverse direction<br>INSERT INTO Edges<br>SELECT RowB, RowA FROM RowMatchPairs;</pre><h3>Add self-edges for standalone records</h3><p>Some rows never match any rule.<br> They still need to appear in the final result.</p><pre>INSERT INTO Edges (FromRow, ToRow)<br>SELECT r.RowNumber, r.RowNumber<br>FROM (<br>    SELECT DISTINCT RowNumber<br>    FROM RuleRowMatch<br>) r<br>WHERE NOT EXISTS (<br>    SELECT 1<br>    FROM Edges e<br>    WHERE e.FromRow = r.RowNumber<br>       OR e.ToRow   = r.RowNumber<br>);</pre><p>At this point:</p><ul><li>matched rows are connected to neighbors</li><li>unmatched rows connect only to themselves</li></ul><p>The graph is complete.</p><h3>Phase 2: Find transitive matches via label propagation</h3><p>Instead of recursion, each record carries a <strong>label</strong> that gradually converges.</p><h3>Initialize labels</h3><pre>CREATE TABLE Labels<br>(<br>    RowNumber INT PRIMARY KEY,<br>    Label     INT NOT NULL<br>);</pre><pre>INSERT INTO Labels<br>SELECT DISTINCT FromRow, FromRow<br>FROM Edges;</pre><p>Each row starts with its own label.</p><h3>Iteratively propagate the minimum label</h3><pre>DECLARE @changed INT = 1;</pre><pre>WHILE @changed &gt; 0<br>BEGIN<br>    ;WITH NeighborMin AS (<br>        SELECT<br>            e.FromRow AS RowNumber,<br>            MIN(l.Label) AS MinLabel<br>        FROM Edges e<br>        JOIN Labels l<br>            ON l.RowNumber = e.ToRow<br>        GROUP BY e.FromRow<br>    )<br>    UPDATE lbl<br>        SET Label = n.MinLabel<br>    FROM Labels lbl<br>    JOIN NeighborMin n<br>        ON n.RowNumber = lbl.RowNumber<br>    WHERE lbl.Label &gt; n.MinLabel;</pre><pre>    SET @changed = @@ROWCOUNT;<br>END;</pre><h3>What this achieves</h3><p>What this achieves is a gradual and controlled resolution of connectivity across the dataset. As labels propagate through neighboring records, each connected set naturally converges toward a shared value, ensuring that all records linked through any chain of matches are resolved together. Transitive relationships emerge implicitly through this process, without the need for explicit path expansion. By avoiding deep recursion and large, ever-growing intermediate result sets, the solution remains both predictable and efficient as the graph grows.</p><h3>Final result</h3><pre>SELECT RowNumber, Label<br>FROM Labels<br>ORDER BY Label, RowNumber;</pre><p>Rows sharing the same label belong to the same transitive match group.</p><h3>Why this approach scales better</h3><p>This approach scales more reliably because it replaces recursive expansion with controlled, set-based iterations. Each iteration performs a bounded aggregation over known relationships, making the work predictable rather than dependent on how many paths the graph happens to contain. Indexes can be applied effectively to edge lookups and neighbor aggregations, allowing the engine to optimize access patterns instead of repeatedly materializing intermediate results. As the dataset grows, the solution degrades gracefully by requiring more convergence steps rather than exploding in runtime or memory usage. The key improvement is not asymptotic complexity, but predictability under real-world data distributions.</p><h3>Closing thought</h3><p>This optimization wasn’t about replacing one SQL trick with another.<br> It was about recognizing the problem as a <strong>graph connectivity issue</strong> and choosing an algorithmic shape that aligns better with how relational engines scale.</p><p>Once that shift is made, the SQL becomes simpler, more predictable, and far more resilient as data grows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46dfeef9bc0c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/scalable-transitive-matching-without-recursive-ctes-46dfeef9bc0c">Scalable Transitive Matching Without Recursive CTEs</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Validation Logic Scales — but Historical Data Doesn’t]]></title>
            <link>https://medium.com/towards-data-engineering/when-validation-logic-scales-but-historical-data-doesnt-9fab25015e7b?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fab25015e7b</guid>
            <category><![CDATA[database-performance]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 02:13:37 GMT</pubDate>
            <atom:updated>2026-02-01T17:11:58.197Z</atom:updated>
            <content:encoded><![CDATA[<h3>When Validation Logic Scales — but Historical Data Doesn’t</h3><p>A data lifecycle pattern for scalable validation using partitioning and metadata-only promotion</p><h3>Introduction</h3><p>Validation logic is one of those components that tends to work quietly in the background — until scale exposes assumptions no one realized were there.</p><p>In many data engineering systems, validation pipelines are designed to evolve. New rules are added, checks become more expressive, and validation frameworks mature alongside business requirements. Historical data, however, rarely evolves at the same pace. Tables that were once small and manageable accumulate years of records, often without revisiting the original storage or access assumptions.</p><p>When validation logic scales faster than the historical data it evaluates, subtle performance and architectural issues begin to surface. This article explores how that mismatch develops over time, why it becomes a problem in large data systems, and how a shift in data organization — rather than query tuning — ultimately resolves it.</p><h3>The Mismatch Between Validation Logic and Historical Data</h3><p>Validation systems usually start simple. Early datasets are small, schemas are stable, and validation checks run quickly. At this stage, most design decisions feel reasonable, even conservative.</p><p>As systems mature, validation logic grows more sophisticated. Rules extend beyond basic field checks into conditional logic, cross-record validation, and historical consistency checks. This evolution is intentional and necessary.</p><p>What often does not change at the same rate is historical data design. Tables originally optimized for ingestion or reporting are now repeatedly scanned to support increasingly complex validation queries. Indexes reflect access patterns from an earlier stage of the system’s life.</p><p>Over time, an imbalance emerges: validation logic assumes scalability, while historical data structures still reflect legacy assumptions.</p><h3>Where Things Start to Break Down</h3><p>As validation logic expands, several issues tend to appear consistently:</p><ol><li><strong>Full historical scans become routine</strong><br> Validation checks that once operated on incremental data now routinely query large historical ranges.</li><li><strong>Indexes no longer align with access patterns</strong><br> Indexes built for reporting or ingestion offer limited benefit for validation queries that filter and aggregate data differently.</li><li><strong>Validation cost grows non-linearly</strong><br> Adding a small number of new rules results in disproportionately large increases in execution time.</li><li><strong>Operational windows shrink</strong><br> Validation jobs begin competing with downstream processes as runtimes grow.</li></ol><p>These issues rarely stem from a single poor decision. More often, they emerge gradually as systems evolve without revisiting earlier architectural assumptions.</p><blockquote><strong><em>Key insight:</em></strong><em> Validation systems should be designed with historical data access patterns in mind from the beginning. Treating validation as a purely logical concern — separate from physical data design — almost always leads to scalability issues later.</em></blockquote><h3>The Architectural Solution: Partitioned Validation with Bidirectional SWITCH</h3><p>The breakthrough came when validation was no longer treated as a query performance problem, but as a <strong>data isolation and lifecycle problem</strong>.</p><p>The key realization was that validation did not require unrestricted access to the entire historical dataset. Instead, it required a controlled way to <strong>temporarily isolate the data under validation</strong>, apply rules efficiently, and then return the data to history once validation completed.</p><h3>Isolating Data for Validation</h3><p>Historical data was organized into a partitioned structure using a stable boundary, such as load date or logical batch identifier. When a set of records required validation, the relevant partition was <strong>switched out of the historical table into a staging table</strong> using a partition-level SWITCH operation.</p><p>The staging table mirrored the historical table exactly — same schema, data types, indexes, constraints, and partitioning scheme. Because the SWITCH operation is metadata-only, no rows were physically moved and no large transactions were generated.</p><p>Validation logic then operated exclusively on this isolated staging partition. This ensured that validation queries ran against a bounded dataset rather than repeatedly scanning the full historical store.</p><h3>Promoting Validated Data Back to History</h3><p>Once validation completed successfully, the same partition was <strong>switched back into the historical table</strong>, again using a metadata-only SWITCH operation.</p><p>This bidirectional use of SWITCH — out of history for validation and back into history after validation — fundamentally changed the system’s cost profile. Validation execution time became independent of total historical data volume, and data promotion became an explicit, atomic step rather than an implicit side effect of query execution.</p><h3>Constraints That Made the Pattern Safe</h3><p>This approach required discipline. For SWITCH operations to be valid and safe, the staging and historical tables had to:</p><ul><li>Have identical schemas and data types</li><li>Share the same partitioning scheme</li><li>Enforce compatible constraints</li><li>Avoid features that prevent switching</li></ul><p>These constraints were not drawbacks; they were what made the operation deterministic, predictable, and operationally safe at scale.</p><h3>How This Changed Validation Strategy</h3><p>After introducing partitioned validation with bidirectional SWITCH operations:</p><ul><li>Validation runtimes stabilized instead of growing over time</li><li>Historical data growth stopped influencing validation cost</li><li>Operational windows became predictable again</li><li>New validation rules could be added without triggering regressions</li></ul><p>Validation shifted from being a hidden performance liability to a controlled, well-defined phase in the data lifecycle.</p><h3>Design Considerations for Scalable Validation</h3><p>Teams building or evolving validation frameworks can apply a few general principles to avoid similar pitfalls:</p><ul><li><strong>Align validation access paths with physical design</strong><br> Partitioning and indexing should reflect how validation queries actually access data.</li><li><strong>Treat validation as a lifecycle step</strong><br> Isolate data for validation, validate it, and promote it explicitly.</li><li><strong>Design for evolution, not just correctness</strong><br> Validation logic will grow; data models should anticipate that growth.</li><li><strong>Measure validation as a first-class workload</strong><br> Validation deserves its own performance metrics, not just correctness checks.</li></ul><h3>Closing Thoughts</h3><p>Validation frameworks tend to mature quickly because they reflect business expectations for data quality. Historical data, by contrast, often carries the weight of past decisions long after those decisions stop being optimal.</p><p>Recognizing the gap between how validation logic evolves and how historical data is stored is the first step toward building systems that scale gracefully. Addressing that gap early — through thoughtful partitioning and metadata-only data movement — can prevent validation from becoming an unexpected bottleneck as systems grow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fab25015e7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/when-validation-logic-scales-but-historical-data-doesnt-9fab25015e7b">When Validation Logic Scales — but Historical Data Doesn’t</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Keep SQL Reports Live While Refreshing Fact Tables]]></title>
            <link>https://medium.com/towards-data-engineering/how-we-keep-sql-reports-live-while-refreshing-fact-tables-359193329447?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/359193329447</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[database-design]]></category>
            <category><![CDATA[reporting]]></category>
            <category><![CDATA[etl-tool]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 05:17:01 GMT</pubDate>
            <atom:updated>2026-02-04T09:31:24.824Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A real-world pattern using views and synonyms to avoid reporting downtime</em></p><p>Reports rarely fail when nothing is happening. They fail when fact tables are being refreshed, and users are still querying them. This article walks through a practical way to refresh SQL reporting tables without breaking live reports.</p><p>In most production systems, reporting tables are never really idle. Even while data is being refreshed, business users expect dashboards and reports to stay available and accurate.</p><p>That expectation usually leads to a familiar setup.</p><p>Transactional databases handle ingestion, cleansing, and calculations. Reporting fact tables — either in the same database or in a separate reporting database — are shaped and indexed specifically for BI tools. Data flows from the transactional side to the reporting side once processing completes.</p><p>So far, so good.</p><p>The real challenge shows when reporting data needs to be refreshed while reports are actively running.</p><p><strong>Where Things Get Tricky</strong></p><p>Refreshing a reporting fact table is rarely just an append.</p><p>In real systems, refresh logic often involves:</p><ul><li>Deleting and reinserting data</li><li>Truncating partitions and reloading them</li><li>Rebuilding aggregates when reference data changes</li></ul><p>During this window, the reporting table is in a temporary state. If a report hits the table at the wrong moment, users may see incomplete data — or, in some cases, query failures.</p><p>Even short refresh windows can become visible in busy reporting environments.</p><p>Decoupling Reports from Physical Tables</p><p>One reliable way to deal with this is to decouple reports from the physical table being refreshed. Instead of pointing reports directly to a table, reports point to a logical object. That object always resolves to the <em>current</em> version of the reporting data.</p><p>In SQL Server, this is commonly done using synonyms or views.</p><p>The idea itself is simple:</p><ul><li>Refresh data somewhere else</li><li>Validate it fully</li><li>Switch reports over only when the data is ready</li></ul><p>The Synonym Pattern (What Many Teams Start With) A common first step is to use SQL Server synonyms.</p><p>Example setup:</p><p><em>CREATE SYNONYM dbo.FactSales_Current FOR dbo.FactSales_A;</em></p><p><em>Reports always query dbo.FactSales_Current.</em></p><p>When a refresh is needed:</p><ul><li>Data is loaded into a second table (FactSales_B)</li><li>Deletes, truncations, or partition reloads happen there</li><li>Row counts, totals, and validations are checked</li><li>The synonym is switched</li></ul><p><em>DROP SYNONYM dbo.FactSales_Current;</em></p><p><em>CREATE SYNONYM dbo.FactSales_Current FOR dbo.FactSales_B;</em></p><p>The switch itself is extremely fast. From a user’s perspective, nothing changes, and they never see partially refreshed data. This pattern works well and is widely used, especially when refresh windows need to be hidden from reporting tools.</p><p>The Rare Failure Case You Only See in Production — There is, however, one subtle issue with synonyms. Switching a synonym requires a drop and create. For a very brief moment, the object simply does not exist.</p><p>In rare timing scenarios:</p><ul><li>A report query starts executing</li><li>The synonym is dropped at the same time</li><li>SQL Server attempts name resolution</li><li>The object cannot be found</li></ul><p>We ran into this as an intermittent <em>“object not found”</em> failure that disappeared on retry — easy to dismiss at first, until it started showing up under load.</p><p>This isn’t common, but in high-concurrency reporting systems, it does happen. Why Views Are Often a Better Fit — A safer alternative is to use a view instead of a synonym.</p><p>With views, the object is never dropped.</p><p>Example:</p><p><em>CREATE VIEW dbo.vw_FactSales_Current AS SELECT * FROM dbo.FactSales_A;</em></p><p>Reports query the view.</p><p>When the refreshed table is ready, the switch is done using ALTER VIEW:</p><p><em>ALTER VIEW dbo.vw_FactSales_Current AS SELECT * FROM dbo.FactSales_B;</em></p><p>This change is metadata-only and atomic:</p><ul><li>The object never disappears</li><li>Existing queries continue running</li><li>New queries see the updated definition</li></ul><p>From the reporting side, the transition is seamless.</p><p>Is This a Common Approach?</p><p>I’ve seen this pattern show up in systems where reporting downtime simply isn’t acceptable.</p><p>The exact implementation varies, but the core idea is always the same: build the new dataset elsewhere, validate it fully, then switch over without exposing users to partial data.</p><p>If you’ve worked with blue/green deployments, this will feel familiar. The difference here is that the switch happens entirely at the database metadata level.</p><p>Final Takeaway</p><p>Refreshing reporting data isn’t just a data problem — it’s an availability problem.</p><p>By adding a logical layer between reports and physical tables, you can:</p><ul><li>Refresh data safely</li><li>Avoid exposing partial results</li><li>Keep reports live at all times</li></ul><p>Both synonyms and views work. But when reporting availability really matters, views tend to be the safer long-term option.</p><p>Designing reporting systems isn’t just about loading data faster. It’s about making sure users never notice when things are changing underneath. Patterns like table switching, synonyms, and views don’t usually show up in tutorials — but they make a real difference once systems are under load.</p><p>If you’re dealing with live reporting refreshes in SQL Server, I plan to write more about patterns that worked for us — and the edge cases that only show up after systems hit production traffic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=359193329447" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/how-we-keep-sql-reports-live-while-refreshing-fact-tables-359193329447">How We Keep SQL Reports Live While Refreshing Fact Tables</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Migrating SSIS from EC2 to Amazon RDS Is Harder Than It Looks]]></title>
            <link>https://medium.com/towards-data-engineering/why-migrating-ssis-from-ec2-to-amazon-rds-is-harder-than-it-looks-525ea6593c87?source=rss-347754263a80------2</link>
            <guid isPermaLink="false">https://medium.com/p/525ea6593c87</guid>
            <dc:creator><![CDATA[Balu Rathinam]]></dc:creator>
            <pubDate>Tue, 27 Jan 2026 05:05:05 GMT</pubDate>
            <atom:updated>2026-02-01T17:11:56.705Z</atom:updated>
            <content:encoded><![CDATA[<p>Hidden architectural constraints when ETL pipelines move to managed databases</p><p>An engineering case study on why a seemingly straightforward SSIS migration from EC2 to RDS introduces unexpected operational and architectural challenges.</p><p>In today’s dynamic technological environment, enterprises strive to modernize infrastructure for improved automation, reduced maintenance needs, and scalable operations. As part of these initiatives, SQL Server workloads are increasingly migrating from Amazon EC2 to Amazon Relational Database Service (RDS) to improve system efficiency, enhance availability, and streamline infrastructure management.</p><p>The exponential growth of transactional data across client databases necessitated the migration, making system reliability, downtime minimization, and resource optimization mission critical. One of the foremost challenges encountered was the uncontrolled expansion of tempdb, which, if left unmitigated, could degrade performance and potentially cause critical process failures. A lift-and-shift strategy was initially adopted to retain existing SQL Server databases with SQL Server Integration Services (SSIS) workflows, aiming for minimal modifications. Despite the advantages of migrating to a managed database service, this transition introduced architectural limitations — most notably, the inability to support SSIS script components, reliance on file-system-based file handling, and constraints related to storage management in the RDS environment. Addressing these challenges while minimizing modifications requires the evaluation of various solutions. The considered approaches included third-party tools and modifying SSIS package execution to read and write directly to Amazon S3, significantly expanding the scope of changes. This case study explores the migration of SSIS packages from an EC2-hosted SQL Server to Amazon RDS, detailing architectural constraints, operational challenges, and strategic adaptations required to maintain workflow execution efficiency, optimize resource management, and ensure system reliability.</p><p>KEYWORDS: Amazon RDS, Cloud Migration, Database Modernization, EC2, ETL Workflows, Job Scheduling, SQL Server, SSIS</p><p><strong>1. INTRODUCTION</strong></p><p>The migration of an application from one platform to another is often driven by the need to leverage the enhanced capabilities, performance, and long-term benefits offered by the updated environment. Such a transition is rarely straightforward; it typically involves numerous moving parts and cross-functional coordination among application teams, DevOps engineers, and database specialists. While the broader strategy and sequencing of tasks involved in full-scale migration are extensive and beyond the scope of this case study, the focus here is intentionally narrowed. This case study focuses on a critical component of the migration effort: the transformation of the Extract, Transform, and Load (ETL) packages. By examining how the communication flows and operational use cases of ETL packages are adapted and migrated as part of the overall process, this study specifically addresses the application-layer engineering challenges involved in enabling time-constrained lift-and-shift migration without altering the core architecture.</p><p>For this migration, the application’s backend was built on the SQL Server, leveraging the SQL Server Integration Services (SSIS) Project Deployment Model to ensure seamless data integration and process automation. By utilizing the SSIS Project Deployment Model, dynamic parameterization was enabled, allowing variables to be passed directly to packages, while environment-specific parameters, such as database connection strings and folder locations, were efficiently managed through environmental parameters [1]. This architecture provides scalability and flexibility and ensures smooth adaptability across multiple environments. The migration scope encompasses a wide range of SSIS packages, from basic validation and data cleansing to complex, dynamic import processes that incorporate script components for file-based data extraction and validation. Previously, these files were within the filesystem of the database server. With migration, the Amazon Simple Storage Service (S3) has been designated as the primary storage solution. However, modifying read/write operations to interact with S3 introduces additional complexity owing to dynamic file structures and movement patterns, necessitating extensive testing and validation [2].</p><p>The primary objective of this migration was to preserve existing SSIS workflows with minimal modifications while leveraging the Amazon Relational Database Service (RDS) to improve scalability and manageability. However, architectural constraints necessitate the re-evaluation of package execution models and file-based workflows to align with cloud-native best practices.</p><p>This study provides an in-depth examination of the challenges encountered, issues observed, and alternative strategies employed to ensure a smooth transition, offering actionable insights for enterprises undertaking similar types of cloud migration.</p><p><strong>2. PREMIGRATION SSIS INTEGRATION AND EXECUTION PATTERNS</strong></p><p>In the EC2-hosted SQL Server environment, the SSIS packages are deeply integrated with database operations, enabling seamless execution. The decision to use SSIS over SQL stored procedures stems from its superior flexibility in managing complex data integrations, handling multisource ETL processes, and providing built-in error handling and logging. Additionally, SSIS offers a visual, drag-and-drop workflow design, making it more intuitive and manageable for ETL development compared to purely script-based approaches.</p><p>The SSIS package execution follows an asynchronous model, meaning that once triggered, the package runs independently without requiring the calling process to wait for completion. This nonblocking behavior ensures that application calls invoking the SSIS do not freeze or delay user interactions, making it ideal for scenarios in which long-running processes should be executed in the background without affecting the front-end performance.</p><p>The SSIS was employed across various critical ETL and data processing workflows, including data extraction, validation, transformation, calculations, and report refreshes.</p><p>The following execution patterns are commonly used:</p><p><strong>Pattern 1:</strong> Direct SQL Job Invocation<br> A user interface (UI) application directly triggers SQL jobs that execute SSIS packages.</p><p><strong>Pattern 2:</strong> UI-Driven Stored Procedures<br> A UI application reads flat files into staging tables, and the stored procedure triggers SSIS workflows to perform data cleansing.</p><p><strong>Pattern 3:</strong> Direct SSIS Execution via Stored Procedures<br> The application calls stored procedures that directly invoke SSIS for ETL processes (which involve flat file extractions).</p><p><strong>Pattern 4:</strong> Scheduled SQL Jobs with No File Transactions<br> Predefined SQL jobs execute stored procedures, which in turn trigger SSIS packages for automated processing.</p><p><strong>Pattern 5:</strong> UI-Driven Stored Procedure Calling SQL Jobs with ETL SSIS Packages</p><p>A UI application calls a stored procedure, which invokes an SQL Agent job; the job then runs an SSIS package involving file extraction and data cleaning.</p><p>Upon migrating to Amazon RDS, these execution patterns face architectural challenges due to the limitations of the SSIS component and the shift from file system storage to Amazon S3.</p><p><strong>3. CHALLENGE 1: SSIS COMPONENT LIMITATIONS AND MIGRATION PATH</strong></p><p><strong>3.1. Problem Statement</strong></p><p>The SSIS packages are commonly used to extract data from various sources. In some packages, dynamic column mapping is required to align source file columns with destination objects — in this case, an SQL Server database. To achieve this, the Script Components play a critical role. However, while standard Amazon RDS supports SSIS, it has limitations: it does not support the SSIS Script Component, restricts connections to sources other than SQL Server or Oracle, and requires extensive modifications to migrate these tasks. This significantly broadens the scope of the changes required to rewrite specific functionalities [3].</p><p><strong>3.2. Design Iteration 1: Hosting SSIS on EC2 and Databases on RDS</strong></p><p>Deploying an SSIS server on EC2 was initially considered a solution that required only minimal modifications to the RDS server to address its limitations. This approach allows SQL jobs that trigger SSIS packages to continue functioning with minimal impact, ensuring seamless execution by simply configuring proper permissions and access between the servers for the service account.</p><p>1) Observations: However, complexity occurred when SSIS packages were invoked from stored procedures, particularly when variables needed to be passed. At this stage, Linked Server configurations became necessary for communication between RDS and EC2. This introduced additional challenges, as the existing stored procedure calls had to be dynamically modified to EXECUTE AS the caller’s context (EXECUTE AS CALLER) [4]. Although technically feasible, the added overhead and constraints make the solution cumbersome.</p><p><strong>3.3. Optimized Design: Migrating to Amazon RDS Custom</strong></p><p>The Amazon RDS Custom has emerged as the optimal solution to eliminate these issues. Unlike standard RDS, RDS Custom allows SSIS installation, enabling seamless execution of script components, integration with diverse data sources, and direct package execution without the need for workarounds [5]. All these complications were resolved by leveraging RDS Custom, providing a simpler and more efficient alternative to the EC2-hosted SSIS approach.</p><p><strong>4. CHALLENGE 2: FILESYSTEM ACCESS RESTRICTIONS AND MIGRATION PATH</strong></p><p><strong>4.1. Problem Definition</strong></p><p>After resolving the script component and data source limitations by migrating to RDS Custom, the next step was to address the shift from file system storage to Amazon S3. The SSIS packages without file movement operated as expected, as discussed in Patterns 1, 2, and 4.</p><p>Most SSIS packages in the system are tightly coupled with the pattern of using the Universal Naming Convention (UNC) path and do not support a direct connection to S3. The Amazon RDS for the SQL Server supports mapping a local folder (e.g., D:\S3) to an S3 bucket [6]; however, this limits the support of the UNC path.</p><p><strong>4.2. Design Iteration 1: Restoring Shared File Access via AWS Storage Gateway</strong></p><p>To maintain a lift-and-shift strategy and minimize the development overhead, a custom file mapping approach using the AWS Storage Gateway was configured on the RDS Custom database host, replicating the original folder structure and enabling seamless SSIS package access without major workflow changes [5]. S3 access and related permissions were provisioned and managed by the platform DevOps team, ensuring adherence to least-privilege principles and alignment with established infrastructure provisioning practices. With this setup, SSIS packages triggered by SQL Agent jobs are executed successfully without issues because they run under the configured proxy account, as in Pattern 5.</p><p>1) Observations: However, in Pattern 3, where the application directly invokes the stored procedure to execute the SSIS package for data extraction and imports, additional adjustments are required (Fig. 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*V6hS6YUxFu4rxKUFvga9Sw.png" /><figcaption><strong>Fig. 1.</strong> Workflow for Triggering an SSIS Package via a Stored Procedure from a Web Application</figcaption></figure><p>Failures occurred when the SSIS packages were invoked from the web application via a stored procedure (with variables passed). In these cases, the SSIS package runs under the application’s account, leading to the errors described below.</p><p><strong>4.2.1 Issue Breakdown</strong></p><p>· The application triggered a stored procedure with the application account, passing the necessary variables.</p><p>· The stored procedure logged these variables in a log table.</p><p>· The stored procedure then invoked an SSIS package, which was responsible for extracting flat files and archiving them to a new folder.</p><p>· During execution, the SSIS package failed, resulting in errors such as “Folder not accessible” or “Folder not found” (see Fig. 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*n0xtI7BLhkY0J4Pp7vXWgw.png" /><figcaption><strong>Fig. 2.</strong> SSIS Workflow Error Encountered During Access to S3-Mounted Folder</figcaption></figure><p>It was observed that the stored procedure executed successfully when run under the same application account in SSMS during a remote server session but failed when triggered via the web application (using EXECUTE AS).</p><p><strong>4.3. Design Iteration 2: Direct SSIS Package Trigger via SQL Job</strong></p><p>Extensive troubleshooting was conducted from an access and permission perspective to identify the root cause, which required significant time and effort. During this period, alternative ETL modernization tools such as AWS Glue, ZappySys, and AWS SDK integrations were also considered; these tools are commonly used for cloud migration. However, based on initial assessments, these approaches would have required either a complete workflow rewrite or significant refactoring of the SSIS package logic, which conflicted with the project’s timeline and the need to maintain system reliability throughout the transition. Given the need to complete the implementation within a defined schedule and with the investigation extending beyond expected timelines, an alternative approach was explored from a development standpoint, prompted by the observation that similar SSIS packages had previously been executed successfully via SQL Server Agent jobs using a proxy account.</p><p>1) Observations: Because the application calls a stored procedure that subsequently invokes an SQL Agent job, this job needs to be triggered without delay (parallel execution must be allowed). Therefore, invoking the SQL job directly from the stored procedure is not acceptable, as the process must allow users to initiate it at any time, and it should not fail if the SQL job is already running.</p><p><strong>4.4. Design Iteration 3: Scheduled SQL Job Polling Log Table for Parameter-Driven SSIS Execution</strong></p><p>Given the challenges of directly calling the SQL job from the stored procedure, an alternative approach was attempted. In this approach, to avoid waiting on call to the SQL job, a logging table was created to store all the variables needed to execute the package. Once a user initiates an export or extract from the application, the selected parameters are passed to the stored procedure, which inserts them into the newly created logging table with a status of “just added” (see Fig. 3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*B5eAZS2_JMXoLsp3JehvrA.png" /><figcaption><strong>Fig. 3</strong>. Application Storing Parameters and Exit</figcaption></figure><p>1) Observations: The SQL job was scheduled to run at a defined interval. Scheduling an SQL job to call the SSIS package worked; however, a key challenge occurred when it had to handle multiple simultaneous export requests. If 10 or more export requests were triggered around the same time, it became necessary to assess their impact on performance. The initial approach relied on an SQL job scheduled to run every minute to invoke an SSIS package. However, this raises the following concerns.</p><p>· The variables logged in the table had to be read and dynamically passed to the SSIS package.</p><p>· If 10 or more requests are queued, the scheduled SQL job processes them sequentially on the basis of the status defined in the logging table, delaying execution and creating a queue-based execution model instead of parallel processing.</p><p><strong>4.5. Design Iteration 4: Routing via a Landing SSIS Package</strong></p><p>Instead of having the SQL Agent job called the SSIS package directly, a new Landing SSIS package was introduced to act as a router. This package receives an indicator parameter (Method_Name) from the SQL Agent job to determine the call source.</p><p>The implementation of this solution follows a defined sequence of steps (see Fig. 4):</p><p>1) The SQL job sends an indicator as a parameter to the Landing SSIS package to identify the calling source.</p><p>2) A common stored procedure loops through the logging table for the specified Method_name, filtering records with a “just added” status (status = 0).</p><p>3) For each entry, the stored procedure retrieves parameters and invokes the original SSIS package.</p><p>4) The indicator in the SQL job used is Method_name in the configuration, allowing the differentiation between various processes (e.g., Extract vs. Export).</p><p>o If the process is an extract, one SQL job sends an indicator in Method_name = “Extract.”</p><p>o If the process is an export, another SQL job sends an indicator in Method_Name = “Export.”</p><p>5) The common stored procedure within the Landing SSIS package dynamically selects the parameters and calls the respective SSIS packages accordingly in a loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*HE9BJdYVwVA58y8ecGegEg.png" /><figcaption><strong>Fig. 4.</strong> SQL Job Schedule and Router Design</figcaption></figure><p>The approach significantly improves the execution speed, with the SQL Agent jobs completing in milliseconds to enable rapid scheduling. By moving away from the queue-based model, the design supports parallel processing, allowing multiple requests to be handled concurrently. This also contributes to efficient resource utilization because SSIS packages are executed promptly without unnecessary wait times. The solution supports handling multiple export or extract requests concurrently, eliminating the sequential queue and significantly reducing the overall processing delay.</p><p>1) Observations: The SQL Agent job is set to run at regular intervals (e.g., every 1–5 min) regardless of workload. As a result, the job is executed even during periods of low or no activity, leading to idle processing. As more methods and clients use the solution, the number of scheduled jobs increases, causing redundant execution. This pattern leads to unnecessary CPU and memory consumption and can introduce spikes in resource usage, thereby affecting scalability. The fixed schedule model creates scalability issues that require further optimization to ensure that SQL Agent jobs are triggered only when actual work is present rather than relying on a continuous schedule.</p><p><strong>4.6. Optimized Design — Enabling On-Demand Scheduling of SQL Jobs</strong></p><p>To address system inefficiencies and improve performance, the solution was extended to dynamically trigger SQL Agent jobs on demand. This triggering occurred within the stored procedure, immediately after the log entry and user parameters from the incoming application request were recorded. (see Fig. 5).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*zg1yBsH3OIyW4aqeIFDrug.png" /><figcaption><strong>Fig. 5.</strong> Activation of the SQL Job Scheduler</figcaption></figure><p>The SQL job initiates a router package that evaluates the context of the request and iterates through log entries specific to the invocation method. For each entry in the log table, a call is made to invoke the main package based on the method. The execution status is then updated to ‘completed’, and the system checks for any additional entries with a ‘started’ status. If more entries exist, the loop continues; otherwise, the job ends the loop and disables itself to avoid unnecessary future executions (see Fig. 6).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*rFFtrmesVhiRRcoExT8QOg.png" /><figcaption><strong>Fig. 6.</strong> Router Package Process</figcaption></figure><p>However, its implementation introduces a few challenges. A key requirement is that the application user must be capable of enabling the SQL job and logging all the relevant parameters. Additionally, to enable the SQL job schedule to pose a constraint, either the application user (who is not a part of any administrative group) must own the SQL job or possess Sysadmin privileges, the latter being discouraged owing to heightened security risks. Thus, the application user becomes the SQL job owner, and as part of the automatic deactivation mechanism, the system checks a designated log table after each execution for the presence of the related method name. If no matching entries are found, the job is programmatically disabled on the schedule, thus preventing future executions unless explicitly re-enabled.</p><p>This approach transforms SQL job execution into an on-demand process, ensuring optimal resource utilization, reduced system load, and improved scalability without compromising security. When configuring a proxy account as the ‘Run As’ identity for executing an SQL Server Agent job, it is essential that the proxy account be listed among the job owner’s authorized principals and granted the necessary impersonation rights. This ensures that, as the SSIS package executes in the proxy context, the process can securely impersonate the main user account to disable the SQL job schedule upon completion. This setup adheres to the SQL Server Agent security framework, which enables privilege-controlled task execution using credential-based proxy delegation [7].</p><p><strong>5. CONCLUSION</strong></p><p>This case study highlights the critical challenges and strategic solutions encountered during the migration of SSIS packages from EC2 to Amazon RDS. Migrating SQL Server workloads from Amazon EC2 to Amazon RDS Custom for SQL Server significantly enhances the observability and control over tempdb usage. In Amazon RDS Custom, administrators can configure Amazon CloudWatch to monitor storage metrics such as FreeStorageSpace, enabling preemptive alerts when tempdb begins consuming excessive disk resources [8]. Furthermore, RDS Custom supports Enhanced Monitoring, which provides granular operating system-level metrics — such as disk I/O, memory usage, and CPU load — that help identify and mitigate abnormal tempdb behavior before it impacts workload performance [9]. These features contrast with those of the EC2-hosted SQL Server instances, which rely on user-managed monitoring stacks that lack native integration and require manual setup and maintenance. Moreover, recent enhancements allow tempdb to be optimized using local instance storage in RDS Custom, reducing I/O contention and improving stability in write-heavy scenarios [10]. By systematically addressing SSIS component limitations, file-system access restrictions, and execution inefficiencies, migration not only preserves existing workflows but also introduces a more scalable and cloud-optimized execution model.</p><p>The adoption of RDS Custom eliminates key constraints, enabling seamless SSIS execution while minimizing architectural disruptions [3]. Additionally, by transitioning from the EC2-maintained filesystem to Amazon S3 for file storage, the solution significantly improved the disk-space efficiency on the RDS Custom instance. Because file handling is now offloaded to S3, which operates independently of the RDS Custom environment, local storage dependencies are eliminated and resource utilization on the database server is optimized. Furthermore, the staging SSIS package approach provides a structured, low-code solution to mitigate execution failures, ensuring operational continuity without requiring major redesigns. As enterprises continue to modernize SQL Server workloads, adapting to cloud-based constraints is essential for long-term efficiency and scalability [11]. This study serves as a proven framework for overcoming migration roadblocks, offering actionable insights, best practices, and innovative execution strategies for organizations transitioning from SSIS-based architectures to the cloud.</p><p>This case study, while centered on a specific migration scenario, demonstrates a broadly applicable solution for environments where SQL Server Agent jobs are prescheduled to wait on event triggers before execution. In such configurations, jobs may continue to run at scheduled intervals without purpose, thus unnecessarily consuming system resources. This inefficiency becomes significant when scaled across numerous jobs that exhibit similar behavior. Key system performance metrics were analyzed to evaluate the effectiveness of the proposed solution. As shown in Table 1, the previous approach to routine job scheduling resulted in significant CPU utilization spikes during each scheduled execution window, with utilization ranging from 70% to 100%. Additionally, concurrent job execution during peak intervals led to high blocking, frequent job failure, and elevated instance wait times owing to resource contention. After implementing the event-driven triggering mechanism, system behavior improved significantly. The CPU utilization was reduced to a range of 5% to 20%, round-trip times decreased from 6 to 2 milliseconds, and blocked sessions were eliminated. The SQL job failure rate decreased to zero, and the overall frequency of job execution was reduced by more than 97.9%, contributing to a substantial reduction in the system load and enhanced reliability. These quantitative improvements demonstrate the effectiveness of the proposed optimization strategy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*k0KDhQf7k7XC-QjmlZ-enw.png" /><figcaption><strong>Table 1</strong> Comparison of SQL Agent job performance before and after migration to event-driven scheduling. Metrics reflect average daily load across 30 staging environments.</figcaption></figure><p>Table 1 summarizes the quantitative performance improvements achieved. The methodology for measurement and the observed system impact are described as follows:</p><p>Performance measurements were conducted to evaluate the system resource utilization and job execution efficiency under the previous continuous scheduling model and new event-driven execution model. In the baseline configuration, the SQL Agent job was scheduled to run every two minutes across 30 staging environments used for preproduction validation and supported three distinct operational method types. Each job execution cycle triggered multiple SQL processes, resulting in approximately 64,800 job executions per day (calculated as: 30 staging environments × 3 methods × 1 execution every 2 minutes × 24 hours).</p><p>During the continuous scheduled execution period, CPU utilization was monitored using SQL Server Dynamic Management Views (DMVs) and operating system–level performance counters. CPU usage consistently exhibited spikes at each scheduled execution point, and the overall resource consumption remained elevated even during periods of low application activity. The round-trip time was defined as the elapsed duration between the job trigger event and the completion timestamp recorded in the system logs.</p><p>Additionally, it was observed that persistent job scheduling led to unintended system overhead: several SQL Agent jobs intermittently failed owing to resource contention, and overall server performance was negatively impacted by the constant execution of background processes that served no purpose during idle periods. Unlike change-data-capture (CDC) mechanisms, which react only to actual data modifications, the prior scheduling model continuously triggers processes regardless of workload conditions, leading to inefficient resource consumption.</p><p>After migrating to an event-driven scheduling model, SQL Agent jobs are triggered only upon application demand. Under a comparable operational load, the number of daily job executions decreased to approximately 1,350 (calculated as: 30 staging environments × 15 average event calls × 3 methods), representing a reduction of over 97.9%. This transition significantly reduced the CPU load, eliminated unnecessary background activity, and contributed to improvements in the round-trip time and job reliability documented in Table 1.</p><p>These results demonstrate the tangible benefits of rethinking the migration and scheduling strategies in constrained environments. This case study demonstrates that innovative, resource-efficient solutions can be achieved entirely within the SQL Server and SSIS ecosystem without relying on external tools or services. Although alternative approaches exist, the methodology presented here delivers operational simplicity, architectural control, and minimized disruption — offering a practical framework for organizations facing similar migration challenges.</p><p><strong>Note on Data and Materials</strong><br> This article focuses on architectural decisions, execution flow, and performance characteristics observed during the migration of SSIS-based workflows from Amazon EC2 to Amazon RDS Custom. It does not analyze or expose raw datasets. All references are based on aggregated system-level metrics and logs from a nonproduction environment and are used solely to illustrate execution trends and performance impact. No sensitive, personal, or client-identifiable information is included.</p><p><strong>About the Author<br> </strong>I’m a data engineer with over 15 years of experience working on large-scale ETL systems, performance optimization, and cloud migrations in healthcare environments. I enjoy breaking down complex data workflows into practical, scalable designs and sharing lessons learned from real production systems. This article is published with employer approval and reflects my own engineering perspective. It discusses architectural patterns and engineering decisions at an aggregated level and does not include any sensitive or client-identifiable information.</p><p>I’m grateful to colleagues and mentors for their thoughtful feedback and encouragement, and to my family for their continued support throughout this work.</p><p><strong>REFERENCES</strong></p><p>1. Microsoft (2025) Deploy integration services (SSIS) projects and packages, <a href="https://learn.microsoft.com/en-us/sql/integration-services/packages/deploy-integration-services-ssis-projects-and-packages.">https://learn.microsoft.com/en-us/sql/integration-services/packages/deploy-integration-services-ssis-projects-and-packages.</a> Accessed: 19 July 2025.</p><p>2. Amazon Web Services (2023) Amazon S3 developer guide, <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html.">https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html.</a> Accessed: 19 July 2025.</p><p>3. AWS Documentation(n.d.) Support for SQL Server Integration Services in Amazon RDS for SQL Server, <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.SQLServer.Options.SSIS.html.">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.SQLServer.Options.SSIS.html.</a> Accessed: 19 July 2025.</p><p>4. Microsoft(n.d.) EXECUTE AS clause (Transact-SQL), <a href="https://learn.microsoft.com/en-us/sql/t-sql/statements/execute-as-transact-sql.">https://learn.microsoft.com/en-us/sql/t-sql/statements/execute-as-transact-sql.</a> Accessed: 19 July 2025.</p><p>5. Amazon Web Services (2023) Working with Amazon RDS Custom, <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-custom.html.">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-custom.html.</a> Accessed: 19 July 2025.</p><p>6. AWS Documentation (2023) Using Amazon S3 with SQL Server, <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/sqlserver-s3-integration.html.">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/sqlserver-s3-integration.html.</a> Accessed: 19 July 2025.</p><p>7. Microsoft (2025) Implement SQL Server Agent security, <a href="https://learn.microsoft.com/en-us/ssms/agent/implement-sql-server-agent-security.">https://learn.microsoft.com/en-us/ssms/agent/implement-sql-server-agent-security.</a> Accessed: 19 July 2025.</p><p>8. Amazon Web Services (2023) Monitoring Amazon RDS metrics with Amazon CloudWatch, <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/monitoring-cloudwatch.html.">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/monitoring-cloudwatch.html.</a> Accessed: 19 July 2025.</p><p>9. Amazon Web Services (2023) Monitoring OS metrics with enhanced monitoring, <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.OS.html.">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.OS.html.</a> Accessed: 19 July 2025.</p><p>10. Amazon Web Services (n. d.) Optimize TempDB performance in Amazon RDS Custom for SQL Server using local instance storage, <a href="https://aws.amazon.com/blogs/database/optimize-tempdb-performance-in-amazon-rds-custom-for-sql-server-using-local-instance-storage/">https://aws.amazon.com/blogs/database/optimize-tempdb-performance-in-amazon-rds-custom-for-sql-server-using-local-instance-storage/.</a> Accessed: 19 July 2025.</p><p>11. Phil Ekins &amp; Alex Zarenin (2022) Why AWS is the cloud that modernizes SQL Server workloads best., <a href="https://aws.amazon.com/blogs/modernizing-with-aws/why-aws-is-the-cloud-that-modernizes-sql-server-workloads-best/">https://aws.amazon.com/blogs/modernizing-with-aws/why-aws-is-the-cloud-that-modernizes-sql-server-workloads-best/.</a> Accessed: 19 July 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=525ea6593c87" width="1" height="1" alt=""><hr><p><a href="https://medium.com/towards-data-engineering/why-migrating-ssis-from-ec2-to-amazon-rds-is-harder-than-it-looks-525ea6593c87">Why Migrating SSIS from EC2 to Amazon RDS Is Harder Than It Looks</a> was originally published in <a href="https://medium.com/towards-data-engineering">Towards Data Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>