Skip to content

DBT Contracts Performance #640

@Benjamin-Knight

Description

@Benjamin-Knight

When contract.enforced = true, the sqlserver__create_table_as macro uses CREATE TABLE + INSERT INTO ... SELECT instead of SELECT INTO. On SQL Server, INSERT INTO a heap is fully logged, while SELECT INTO is minimally logged (in simple/bulk-logged recovery). For high-volume tables this causes the transaction log to fill completely and the query to fail.

Relatively simple fix, adding a tablock to the create table macro for the contract branch will use the same minimal logging when operating under simple/bulk-logged recovery mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions