Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain early-binding views in Postgres and include our pro-tips #4602

Open
1 task done
dbeatty10 opened this issue Dec 6, 2023 · 0 comments
Open
1 task done

Explain early-binding views in Postgres and include our pro-tips #4602

dbeatty10 opened this issue Dec 6, 2023 · 0 comments
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@dbeatty10
Copy link
Contributor

dbeatty10 commented Dec 6, 2023

Contributions

  • I have read the contribution docs, and understand what's expected of me.

Link to the page on docs.getdbt.com requiring updates

https://docs.getdbt.com/reference/resource-configs/postgres-configs

What part(s) of the page would you like to see updated?

Add new section called "Early binding views" between "Performance optimizations" and "Materialized views", just like the docs for dbt-redshift.

The new context might look like this:

### Early binding views
Unlike Redshift, Postgres does not support [views](https://docs.getdbt.com/terms/view) unbound from their dependencies ([late binding views](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_VIEW.html#late-binding-views)). In practice, this means that if upstream views or tables are dropped with a cascade qualifier, any view that depends on it will get dropped as well.

To avoid having data that is unavailable to consumers during a dbt build, our recommendation is to use the [`table` materialization](https://docs.getdbt.com/docs/build/materializations#table) for any relations that are exposed to consumers.

Key insight

When a table is recreated in Postgres, any views that depend upon it will be deleted automatically and will need to be recreated. They will be unavailable in the meantime and data access attempts will return a database error.

This is because postgres only supports early-binding views (as opposed to most other cloud data warehouses). As a derivative of Postgres, Redshift also uses early-binding views, but it allows late-binding as a configuration option. BigQuery, Spark, and Databricks only have late-binding views.

Our recommendations

  • In Redshift, use late-binding views across the board
  • In Postgres, use tables (rather than views) for any data sets that are exposed to consumers

Additional information

No response

@dbeatty10 dbeatty10 added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels Dec 6, 2023
@dbeatty10 dbeatty10 changed the title Check if we explain Postgres early-binding views and include our pro-tips Explain early-binding views in Postgres and include our pro-tips Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
Development

No branches or pull requests

1 participant