Area: Ingestion
Sub-Area: Performance
Applies to: OSS + Cloud
Issue
Snowflake ingestion is slow, or reads more from Snowflake than you need. You can reduce the work by narrowing the recipe's scope, keeping the lineage and usage window short, and turning off optional features you don't use.
You Might Be Asking
- Why is my Snowflake ingestion so slow?
- How can I speed up Snowflake metadata extraction?
- Can I reduce the amount DataHub reads from Snowflake?
Cause
The recipe controls what DataHub reads from Snowflake: which databases and schemas it covers, how long the lineage and usage window is, and which optional features are on. Every fix below is a recipe change or a CLI version change that you control. You don't need to change any server setting, so Cloud and OSS customers follow the same steps.
Solution
1. Limit the scope with patterns
Use database_pattern and schema_pattern to ingest only what you need. Keep these rules in mind:
- Patterns are Python regular expressions. They match from the start of the name only, so
prodalso matchesprod_eastandproduction. Anchor with^...$for an exact match. - Setting
allowreplaces the default allow list of['.*']. Only names that match one of your allow patterns, and no deny pattern, are ingested. - Deny wins over allow. A name that matches any deny pattern is excluded even if it also matches an allow pattern.
- Matching ignores case by default.
- With the default
match_fully_qualified_names: false,schema_patternis matched against the bare schema name. A pattern like^analytics\..*then matches nothing, and every schema is filtered out. To filter by database and schema together, setmatch_fully_qualified_names: true.schema_patternis then matched against<database>.<schema>. DataHub logs a warning when you setschema_patternwithout it, and saystruewill become the default. -
.is a regex wildcard. Escape it as\.and put the pattern in single quotes. In a YAML double-quoted string,\.is not a valid escape and the recipe fails to load. - Patterns compile the first time they are used, so an invalid regex only fails at run time.
source:
type: snowflake
config:
match_fully_qualified_names: true
schema_pattern:
allow:
- '^ANALYTICS\..*'
deny:
- '.*_BACKUP$'
The connector always denies .*INFORMATION_SCHEMA$ for schemas.
The default database_pattern denies ^UTIL_DB$, ^SNOWFLAKE$ and ^SNOWFLAKE_SAMPLE_DATA$. If you set database_pattern yourself, your value replaces that whole default, deny entries included. Nothing adds those three denies back. If your pattern can match those databases, list them in deny again.
2. Keep the lineage and usage window small
The Snowflake source has no lookback_days option. The window is set by start_time and end_time. end_time defaults to now (UTC). start_time defaults to the last full day (UTC), because bucket_duration defaults to DAY. A value such as start_time: '-7d' makes the window seven times longer than the default. Set it only if you need more history.
3. Turn off features you don't need
source:
type: snowflake
config:
include_column_lineage: false
include_usage_stats: false
include_queries: false
include_query_usage_statistics: false
exclude_dynamic_tables: true
-
include_column_lineageneedsinclude_table_lineage: true. If you setinclude_table_lineage: false, setinclude_column_lineage: falseas well, or validation fails. -
include_view_lineageandinclude_view_column_lineagewere removed in December 2024. DataHub drops them with a warning, so they don't disable anything. Remove them from your recipe. -
exclude_dynamic_tablesis described in the config as a way to speed up ingestion if you don't need dynamic tables. -
include_queriesandinclude_query_usage_statisticsboth default to true and apply to queries v2, which is the default (use_queries_v2: true). - Recipes reject unknown keys, so a misspelled option stops the run before it starts.
4. Use profiling sparingly
Profiling is off by default (profiling.enabled: false). Setting profiling.enabled: true alone turns on column-level stats. If you enable it, limit it:
source:
type: snowflake
config:
profiling:
enabled: true
profile_if_updated_since_days: 7
-
profile_patternis a top-level source option besideprofiling. Nesting it insideprofilingfails validation. Only tables thattable_patternallows are considered. -
profile_if_updated_since_daysprofiles only tables that changed in the last N days. The default is no limit. - Snowflake profiling skips large tables by default:
profile_table_size_limitdefaults to 5 (GB) andprofile_table_row_limitdefaults to 5,000,000 rows. Setting either tonullremoves the limit. -
use_samplingdefaults to true withsample_size10000. Settinguse_sampling: falsecomputes column stats on the full table, at higher warehouse cost. -
profiling.max_workersonly sets the number of profiling threads (default 5 x CPU count). It does not affect accuracy. - Profiling needs
include_technical_schema: true.
See Reducing profiling cost for more.
5. Skip lineage and usage windows you already processed
remove_stale_metadata (default true) only soft-deletes entities that are missing from the run. It does not make ingestion incremental. To skip lineage and usage windows that earlier runs already processed, turn on stateful ingestion and set enable_stateful_time_window as a top-level source option:
source:
type: snowflake
config:
stateful_ingestion:
enabled: true
enable_stateful_time_window: true
Don't nest enable_stateful_time_window under stateful_ingestion. That fails validation. The option turns itself off when stateful ingestion is disabled.
6. Leave the lazy schema resolver on
lazy_schema_resolver defaults to true. If you set it to false and also set any of include_technical_schema, include_tables or include_views to false, DataHub bulk loads every schema it holds for the recipe's platform, platform instance and env before parsing SQL. The bulk load ignores your database, schema and table patterns. Search the run log for Fetching schemas for platform and Finished loading ... schema info to see how long it took. Don't search by line number, because module line numbers change between CLI versions.
7. Databases with more than 10,000 views
Snowflake SHOW commands return at most 10,000 rows. Older CLIs paged SHOW VIEWS for the whole database by view name. Past 10,000 views, that paging can silently drop views, return some twice, or never finish. It does not raise an error. Upgrade to CLI 1.7.0.20 or later. It pages per schema and needs no extra setting. In UI ingestion, set the version under the source's Advanced Settings, CLI Version.
fetch_views_from_information_schema is no longer needed for this. It also needs a running warehouse and does not report materialized views.
8. Choose the warehouse
Set warehouse in the recipe to the warehouse you want DataHub to use:
source:
type: snowflake
config:
warehouse: "DATAHUB_INGESTION_WH"
DataHub connects with the recipe's warehouse. It does not change result caching or warehouse settings.
9. Split one large account across recipes
You can split one Snowflake account across several recipes with database_pattern or schema_pattern. Use the same platform_instance in every recipe for the same account. platform_instance is part of every dataset URN. Different values create duplicate datasets and break lineage between tables that different recipes ingest.
10. Find the slow phase
For CLI runs, use datahub --debug ingest -c recipe.yaml. The --debug flag goes before the subcommand. For UI runs, turn on Debug Mode under the source's Advanced Settings. Recipes have no debug or debug_mode key, and either key fails validation.
Additional Notes
- Lineage, usage, tags and copy history come from
SNOWFLAKE.ACCOUNT_USAGEviews. The DataHub docs give these views a latency of 45 minutes to 3 hours, so very recent activity may not appear in a run. No recipe option switches these toinformation_schema.