Area: Ingestion
Sub-Area: Profiling
Applies to: OSS + Cloud
Issue
Data profiling takes a long time on large tables, hits timeouts, or makes the ingestion run fail. This usually happens when profiling is on for very large tables, or when it computes expensive metrics on every column.
You Might Be Asking
- How do I speed up data profiling?
- Can I profile only specific tables?
- What is the difference between table-level and column-level profiling?
- How do I set a query timeout for profiling?
- Why does my recipe fail validation after I changed profiling settings?
Cause
Profiling runs queries against your source. The cost grows with table size, the number of columns, and the metrics you turn on. Quantiles, distinct value frequencies, histograms and sample values cost the most. The settings below limit which tables are profiled and how much work each table needs. Examples use Snowflake. Other SQL sources use the same profiling keys, but some keys work only on some platforms. See the SQL Profiling guide and the Snowflake source configuration for the full key list.
Solution
1. Skip very large tables and sample the rest
source:
type: snowflake
config:
profiling:
enabled: true
# Size in GB, not rows. Tables larger than this are skipped.
profile_table_size_limit: 5
# Tables with more rows than this are skipped, not sampled.
profile_table_row_limit: 5000000
# Sampling on Snowflake and BigQuery
use_sampling: true
sample_size: 10000
-
profile_table_size_limitis a size in GB. The default is 5.nullmeans no limit. Tables over the limit are skipped, not sampled. It works on Snowflake, BigQuery, Databricks, Oracle and Teradata. -
profile_table_row_limitis a skip threshold, not sampling. Tables with more rows than the limit are skipped. The default is 5000000.nullmeans no limit. It works on Snowflake, BigQuery and Oracle. On Snowflake, BigQuery and Redshift, a table over either limit still gets a table-level profile (row count, column count, size). Only column-level profiling is skipped. -
use_sampling(defaulttrue) andsample_size(default 10000 rows) work only on BigQuery and Snowflake. Column-level stats are computed on the sampled rows.
If column stats disappear for a table after you lower a limit, that limit skipped it. Set report_dropped_profiles: true to list the tables and columns that were not profiled. The run report also counts skipped tables in profiling_skipped_size_limit, profiling_skipped_row_limit, profiling_skipped_not_updated and profiling_skipped_table_profile_pattern. The SQL Profiling guide explains sampling and how row count differs from column stats.
2. Turn off expensive metrics
source:
type: snowflake
config:
profiling:
enabled: true
turn_off_expensive_profiling_metrics: true
This turns off quantiles, distinct value frequencies, histograms and sample values. It also limits profiling to 10 columns unless you set max_number_of_fields_to_profile.
3. Profile only the tables you need
Set profile_pattern under source.config, not under profiling. Use single quotes around regexes. Only tables that table_pattern also allows are considered.
source:
type: snowflake
config:
profile_pattern:
deny:
- '.*_staging$'
- '.*_temp$'
profiling:
enabled: true
profiling.allow_deny_patterns is not a valid key. Recipe validation rejects unknown keys in source.config. For Databricks, profiling.pattern is also available and matches catalog.schema.table. See the Databricks source configuration.
4. Choose table-level or column-level profiling
To skip field-level metrics, use table-level profiling only:
source:
type: snowflake
config:
profiling:
enabled: true
profile_table_level_only: true
Do not combine profile_table_level_only: true with max_number_of_fields_to_profile or with any include_field_* key set to true. Validation fails with max_number_of_fields_to_profile should be set to None or Cannot enable field-level metrics if profile_table_level_only is set.
For column-level profiling, keep profile_table_level_only false and turn off the costly metrics:
source:
type: snowflake
config:
profiling:
enabled: true
profile_table_level_only: false
max_number_of_fields_to_profile: 10
include_field_null_count: true
include_field_min_value: true
include_field_max_value: true
include_field_mean_value: true
# Skip these to save time
include_field_distinct_count: false
include_field_sample_values: false
include_field_histogram: false
5. Profile less often
profiling.operation_config runs profiling on only some days of a daily schedule. When lower_freq_profile_enabled is on and today does not match, profiling is skipped for that run.
source:
type: snowflake
config:
profiling:
enabled: true
operation_config:
lower_freq_profile_enabled: true
profile_day_of_week: 6 # 0 = Monday, 6 = Sunday
Use profile_date_of_month (1 to 31) to pick a day of the month instead.
profile_if_updated_since_days works on Snowflake, BigQuery and Dremio. On Snowflake and BigQuery it skips tables that were not updated in the last N days. On Dremio it compares against DataHub's last-profiled timestamp, so it controls how often a table is profiled.
6. Set a query timeout
Use profiling.query_timeout_seconds. There is no profiling.query_timeout key.
source:
type: postgres
config:
profiling:
enabled: true
query_timeout_seconds: 300
profiling_isolation_level: AUTOCOMMIT
query_timeout_seconds is a per-statement limit on the database server. It works only on MySQL and Postgres. Other platforms, including Snowflake, ignore it. The SQL Profiling guide recommends pairing it with profiling_isolation_level: AUTOCOMMIT.
If you still need help tuning profiling, log a ticket with DataHub Support.
Related Documentation
Tags: profiling, performance, sampling, timeouts, large-tables, optimization, ingestion, statistics, column-profiling