When to Use Append Method
- Event logs
- Immutable data
- Time-series data without updates
- When duplicates are acceptable
- Audit trails
- High-volume data capture with minimal processing
Advantages and Trade-offs
Example Implementation
- New records are simply appended to the table
- No updates are made to existing records
- Note that
unique_keyis not required
How It Works
When you run an append-only incremental model, dbt:- Creates a temporary table with all the data from your query
- Inserts all records from the temporary table into the target table
- No deletion or updating of existing records occurs
Step By Step Guide: Delete+Insert Method Implementation
Let’s see how the delete+insert method works with a practical example. Initial Setup First, follow the same initial setup as described in the “Using Merge for Incremental Models” page:- Create the staging model with test data
- Run the staging model
- Create the initial incremental model
- Run the incremental model
Testing Append Method
- Update incremental model config:
- Run incremental model with full refresh to start clean:
- Verify initial state:
- Update staging data to trigger append:
- Run both models:
- Verify append results:
Handling Duplicates with Append Method
Since append can create duplicate records, you may need strategies to handle this downstream:- Window Functions: Use window functions to identify the most recent version of each record:
- Materialized Views: Some warehouses support materialized views that can automatically deduplicate
- Downstream Models: Create downstream models that specifically handle deduplication logic
Best Practices for Append Method
- Monitor Table Growth - Since records are only added, implement a strategy to manage table size
- Consider Partitioning - For very large tables, partitioning by date can improve query performance
- Plan for Deduplication - If uniqueness matters for downstream consumers, build deduplication into your models
- Use with Time-Series Data - Append-only is ideal for time-series data where historical accuracy is important