flexanalytics / dbt_observability

Apache License 2.0
1 stars 0 forks source link

Improve model row count #1

Open ataft opened 6 months ago

ataft commented 6 months ago

The current logic to get row_count for models uses select * ... and has two potential issues:

  1. There can be hundreds or thousands of models, many of which you may not want to observe. You may only want to observe tables and not views. You may only want to observe the /models/marts folder. You may only want to observe models that were compiled, meaning they were part of the dbt build.
  2. Select * can be slow. For tables, many data warehouses have faster ways to get table row count, for example: a) Snowflake: https://www.metaplane.dev/blog/three-ways-to-retrieve-row-counts-for-snowflake-tables-and-views b) Redshift: https://www.metaplane.dev/blog/three-ways-to-retrieve-row-counts-in-redshift-tables-and-views

Ideas:

  1. Configure rowcount logic as a variable with the following options: a) DISABLED - do not get rowcount b) SELECT - use select count(*) c) META - use the metadata methodology, depending on database adapter (snowflake, redshift, etc.)
  2. Configure rowcount selector, e.g. only observe "/models/marts" folder
MiConnell commented 5 months ago

current implementation allows for only observing paths or materializations, but there should be a new var added in order to keep observing models but skip the rowcount for performance improvements. something like dbt_observability:rowcount_enabled that would take a list of materializations or paths to be opted in to rowcount tracking