# Mark "first" snapshot?

**URL:** <https://discourse.getdbt.com/t/mark-first-snapshot/16942>\
**Category:** Help\
**Tags:** snapshots, dbt-core\
**Created:** [November 11, 2024, 8:41pm UTC](https://discourse.getdbt.com/t/mark-first-snapshot/16942 "2024-11-11T20:41:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alevy](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@alevy](https://discourse.getdbt.com/u/alevy)\
**Post date:** [November 11, 2024, 8:41pm UTC](https://discourse.getdbt.com/t/mark-first-snapshot/16942/1 "2024-11-11T20:41:31Z")

</div>

I’d like to treat the initial snapshot for a given source record differently in downstream queries in a performant fashion. I could certainly sub-select in my staging table on top of the snapshot table, but that seems inefficient.

Is there a way I can add either a sequence number or an `initial` boolean to the snapshots table itself and set it when the snapshot is created?

---

<div class="post-metadata">

**Author:** ![a\_slack\_user](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/a_slack_user/32/1629_2.png) [@a\_slack\_user](https://discourse.getdbt.com/u/a_slack_user)\
**Post date:** [November 11, 2024, 9:29pm UTC](https://discourse.getdbt.com/t/mark-first-snapshot/16942/2 "2024-11-11T21:29:01Z")

</div>

You could try setting a flag or something in a post-hook after your snapshot runs. We took the inefficient route of building all of our staging tables based on the max\_date for each pkey

Note: `@Jeff Green (CHG Healthcare)` originally [posted this reply in Slack](https://getdbt.slack.com/archives/CBSQTAPLG/p1731360535675229?thread_ts=1731357712.758779&cid=CBSQTAPLG). It might not have transferred perfectly.

---

<div class="post-metadata">

**Author:** ![alevy](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@alevy](https://discourse.getdbt.com/u/alevy)\
**Post date:** [November 11, 2024, 11:51pm UTC](https://discourse.getdbt.com/t/mark-first-snapshot/16942/3 "2024-11-11T23:51:06Z")

</div>

Thanks - I think that’s the right solution. We’ll see how well computing row\_number() in a post-event hook scales performance wise…I doubt I’ll notice it. But the hook feels like the idiomatic approach here, and I like that it’s self-contained within the snapshot configuration which should increase maintainability.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [November 18, 2024, 11:51pm UTC](https://discourse.getdbt.com/t/mark-first-snapshot/16942/4 "2024-11-18T23:51:11Z")

</div>

Closed on November 18, 2024, 11:51pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
