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

Allow enabling/disabling stats collection on catalog table using env var #1048

Closed
wants to merge 1 commit into from

Conversation

aranke
Copy link
Member

@aranke aranke commented May 16, 2024

Problem

We're consuming a lot of memory populating the stats fields in catalog, since we have 1 record per column in information_schema.

Solution

Allow disabling collection of the stats fields from information_schema to save memory.

On ad-hoc testing with my personal schema in Snowflake, this has resulted in a 20% memory decrease (690 MB → 550 MB).

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@aranke aranke requested a review from a team as a code owner May 16, 2024 21:36
@cla-bot cla-bot bot added the cla:yes label May 16, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-snowflake contributing guide.

@aranke aranke marked this pull request as draft May 16, 2024 21:36
@aranke aranke force-pushed the catalog_enable_stats branch from 34b3aad to 361d196 Compare May 16, 2024 21:44
@aranke aranke requested a review from peterallenwebb May 16, 2024 21:47
@@ -37,6 +37,8 @@


{% macro snowflake__get_catalog_tables_sql(information_schema) -%}
{%- set enable_stats = env_var('DBT_CATALOG_TABLE_ENABLE_STATS', 'true') == 'true' -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there precedent for using an env_var this way in macros? I suspect the Adapters team might want us to have an official flag for this.

@jtcohen6
Copy link
Contributor

@aranke @peterallenwebb Thanks for the productive investigation here!

Following on this afternoon's conversation, we're going to investigate the possibility of decomposing table-level and column-level metadata/stats into two separate queries. If we decide we want that behavior to be conditional, it should be via first-class flag (CLI option / env var).

In the meantime, I'm going to close this PR.

@jtcohen6 jtcohen6 closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants