<@U0A71G31CDV> 好啊!We run StarRocks 3.5.19 in share...
# questions-and-troubleshooting
i
@Rocky 好啊!We run StarRocks 3.5.19 in shared-data mode, querying external Iceberg tables. Query-triggered statistics collection intermittently stalls: the pending queue reaches 100, and an FE restart restores collection. Can we use Spark’s Iceberg compute_table_stats procedure to generate Puffin NDV statistics that StarRocks 3.5.19 consumes, reducing our dependence on StarRocks’ query-triggered ANALYZE? For example, in Spark: CALL lake.system.compute_table_stats( table => ‘db.transactions’, columns => array(‘customer_id’, ‘account_id’) ); Please clarify specifically for 3.5.19: 1. Does this version consume the Puffin NDV statistics generated by that procedure? 2. Are these settings sufficient, and what scope applies to each? ◦ Catalog property: enable_get_stats_from_external_metadata = true ◦ Session variables: enable_iceberg_column_statistics = true and enable_read_iceberg_puffin_ndv = true 3. Do existing StarRocks ANALYZE statistics take precedence, even when stale? How can we make StarRocks use the Iceberg metadata statistics? 4. Can we disable enable_query_trigger_analyze and rely on Iceberg manifests plus Spark-generated Puffin statistics? What optimizer limitations would remain? 5. How can we verify that a query actually uses the Spark-generated NDV, including metadata refresh requirements?Please provide relevant documentation or source references and a minimal validation procedure for 3.5.19.
r
Short answer Two of your three settings are real and documented (in source at least); the third I could not confirm. And I can't confirm from the docs that 3.5.19 consumes Spark-written Puffin files specifically — you'd have to validate empirically. ────────── 1. Does 3.5.19 consume Puffin NDV from Spark's
compute_table_stats
?
Partially confirmable. The system variable
enable_iceberg_column_statistics
is documented as: "Whether to obtain column statistics, such as
min
,
max
,
null count
,
row size
, and
ndv
(if a puffin file exists). When this item is set to
false
, only the row count information will be collected."
Default
false
, introduced v3.4 — so it exists in 3.5. That wording implies StarRocks reads NDV from a Puffin statistics file when one is present. Iceberg statistics files are exactly what
compute_table_stats
writes, so this is plausibly compatible. What I could not confirm: that 3.5.19 reads statistics files written by the Spark procedure (as opposed to Iceberg's own writer), which Puffin sketch encoding it accepts, or any 3.5.19-specific behavior. Neither the docs nor the source lookup gave me that. Treat "yes" as a hypothesis to test with the procedure in §5, not a guarantee. 2. Are the settings sufficient, and what scope applies? •
enable_iceberg_column_statistics
— system variable, session scope (default
false
). This is the one you actually must turn on. Set it with
SET
in the session, or
SET GLOBAL
so new sessions inherit it. Introduced v3.4. •
enable_read_iceberg_puffin_ndv
— system variable, boolean, default
true
, present in branches 3.5/4.0/4.1/4.2/main. Note: the official docs do not describe it; the only confirmation is the source-level name lookup. Since it defaults to
true
, it is not required for your setup unless something set it to
false
. •
enable_get_stats_from_external_metadata
— I could not verify this exists. No doc, FE-config entry or source-name lookup returned it, and the Iceberg catalog property docs don't list it. Do not put it in a
CREATE/ALTER CATALOG
statement until you've confirmed the name against the source of your 3.5.19 build (grep
CatalogProperties
/
IcebergCatalogProperties
in the FE source) — an unknown catalog property is at best silently ignored, at worst rejected. So minimally:
SET enable_iceberg_column_statistics = true;
(and leave
enable_read_iceberg_puffin_ndv
at its default). 3. Do stale StarRocks ANALYZE stats take precedence? Likely yes, but I did not find a 3.5-specific statement of the precedence rule. The one piece of evidence I found is a 4.1.7 fix description: rows whose coverage metadata is unusable "fall back to the connector's own table statistics" — implying StarRocks-collected statistics (
_statistics_.external_column_statistics
) are primary and connector/metadata statistics are the fallback. That is 4.1-era wording, not a 3.5 doc guarantee. To force Iceberg metadata statistics to be used, the documented tools are: •
DROP STATS <table>
(listed in the external-table collection section), so there are no stored StarRocks rows to win the precedence contest; •
SET enable_query_trigger_analyze = false
so no new rows get created. I could not confirm whether 3.5.19's fallback actually consults Puffin once stored stats exist but are stale — test it rather than assume. 4. Can you disable
enable_query_trigger_analyze
and rely on Iceberg metadata + Puffin?
Yes as a mechanism —
enable_query_trigger_analyze
is a session variable (default
true
, introduced v3.4), and metadata-derived statistics (row count, `min`/`max`,
null_count
, value counts) are always available; Puffin adds NDV only when
enable_iceberg_column_statistics = true
. Remaining optimizer limitations (documented): • No histograms on external tables other than Hive — histogram collection "is only supported on Hive external tables". So no skew/MCV information for Iceberg.
• Multi-column joint NDV exists since v3.5.0 but is described as manual collection only; I could not confirm it works for external Iceberg tables at all — assume not. • Iceberg NDV from a Puffin sketch is approximate by nature; min/max/null-count from manifests are per-file metrics aggregated, and were unreliable enough to cause a documented full-scan regression (fixed in 3.5.17 / 4.0.10 / 4.1.1 — you're past that at 3.5.19). Also relevant to your stall: the symptom you describe (pending queue pinned at 100 — that's
connector_table_query_trigger_analyze_max_pending_task_num
, default 100 — and an FE restart clearing it) matches a known issue logging
trigger skip | table_uuid=... reason=running_task
, fixed in 4.1.7 and 4.0.17, with no 3.5 backport. If that's your bug, disabling query-triggered ANALYZE is a workaround, not a fix; upgrading is the documented fix. 5. Verifying that a query actually uses the Spark NDV Caveat first: on 3.5.19 the query profile's per-table
StatsSource
is not a reliable indicator. A known issue makes it report
NONE
for Iceberg metadata-based scans even when the estimate is correct; fixed in 4.1.4, no backport to 3.5. Minimal procedure: 1. Spark side: run
compute_table_stats
for
customer_id
,
account_id
as in your example, then confirm a statistics file was actually committed to the table metadata (check the Iceberg metadata JSON for a
statistics
entry / query the Iceberg statistics metadata table from Spark). Without a committed statistics file there is nothing for StarRocks to read. 2. StarRocks, clear the competing stats:
Copy code
sql
   SELECT * FROM _statistics_.external_column_statistics
    WHERE table_name = 'transactions';   -- expect rows if ANALYZE ran
   DROP STATS lake.db.transactions;
   SET enable_query_trigger_analyze = false;
   SET enable_iceberg_column_statistics = true;
3. Refresh metadata so the new snapshot/statistics file is visible:
REFRESH EXTERNAL TABLE lake.db.transactions;
(the cached table entry otherwise reloads on
iceberg_table_cache_refresh_interval_sec
, default 60s;
iceberg_meta_cache_ttl_sec
defaults to 86400). 4. Read the estimate:
EXPLAIN LOGICAL
/
EXPLAIN VERBOSE
on a query whose cost depends on the NDV, e.g. a group-by or join on
customer_id
, and compare the scan/aggregate
Estimates: {row: ...}
before vs. after the Spark run. A change tracking the Spark NDV is your positive signal; no change means either the file isn't consumed or stored stats still win. 5. Cross-check:
SHOW STATS META WHERE table = 'transactions'
to confirm no StarRocks-collected stats remain for the table. ────────── What I could not confirm, summarized: existence of `enable_get_stats_from_external_metadata`; that 3.5.19 reads Spark-written Puffin sketches and which encoding; the exact precedence rule between
external_column_statistics
and connector statistics on 3.5; multi-column/external applicability of joint NDV. For those, check
branch-3.5
source (
IcebergMetadata
,
IcebergTableStatistic*
,
CatalogProperties
) or ask in the StarRocks community Slack/forum. References • using_starrocks/Cost_based_optimizer.md • data_source/feature-support-data-lake-analytics.md • data_source/catalog/iceberg/iceberg.md • administration/configuration/FE_parameters/stats_storage.md • administration/configuration/FE_parameters/user_query_loading.md • administration/configuration/FE_parameters/shared_lake_other.md
i
@Rocky check in version 4.1.7
r
Checked — and I need to correct one thing I said The 4.1.7 fix is real, and the details match your symptom more precisely than I stated before. But my "no 3.5 backport" claim was wrong in an important way. What the known-issue record says (fix PR #80329): • Title: External table statistics collection stops until FE restart. • Fixed in 4.1.7 and 4.0.17. • The fix is merged on
branch-3.5
but was not yet released there as of 2026-11-11
— it is slated for the next 3.5 patch release. So 3.5.19 does not have it. • Symptom: query-triggered statistics collection for external tables gets permanently stuck; every log line for the affected table reports the trigger being skipped because a task is running, while the analyze pool sits idle (0 active, 0 queued) and global dictionary updates stop too. Only an FE restart recovers it. • Log signature:
trigger skip | table_uuid=... reason=running_task
• Trigger conditions: query-triggered analyze on external tables; more than one analyze task for the same table; analyze thread pool full (n threads plus a queue of n); running-concurrency limit reached (default 2). • Fix mechanism: stops the analyze queue from overwriting or leaking running-task entries and keeps the periodic scheduler alive after an error. • Workaround on affected versions: restarting the FE (only thing that recovered it). Caveat on your specific observation: you describe the pending queue reaching 100 (
connector_table_query_trigger_analyze_max_pending_task_num
, default 100, confirmed in the FE config docs). The known issue describes the opposite shape — pool idle at 0 active / 0 queued with
running_task
skips. They may be the same underlying leak observed at different moments, but I can't confirm that from the docs. Check your FE log for the literal
reason=running_task
string: if it's there, this is your bug. One nuance: I could not find PR #80329 listed in the 4.1.7 release-notes bug-fix text I retrieved (that list includes a different analyze item, #81028 "An analyze job stopped collecting the remaining tables after one table failed"). The fix is documented in the known-issues record rather than the release-notes passage. The 3.5.20 release notes I retrieved also did not show #80329, but that passage was truncated, so I can't confirm whether 3.5.20 includes it — check the 3.5.20 release notes for #80329 directly before planning an upgrade. Second correction: the StatsSource issue Confirmed as I said, with the PR now identified: 4.1.4 bug fix _"Iceberg/Delta metadata-derived statistics are now tagged with `StatsSource=TABLE_METADATA`"_ — #76560. Known issue: no backport on 4.0 or 3.5. So on 3.5.19, a profile showing
StatsSource = NONE
for an Iceberg scan tells you nothing about whether the metadata estimate was used — my §5 advice to judge by
EXPLAIN
row estimates rather than the profile label stands. Net effect on your plan Disabling
enable_query_trigger_analyze
on 3.5.19 is still the right workaround for the stall, and it's consistent with moving NDV collection to Spark. But it does not fix the underlying FE bug, which is still present in 3.5.19 and reaches you in a later 3.5 patch. Note that turning the trigger off also stops the low-cardinality dictionary updates that the same scheduler drives (per the known-issue description), so watch for plan changes on low-cardinality columns. Nothing else in my earlier answer changes:
enable_iceberg_column_statistics
(session var, default
false
, v3.4+) is the switch that matters;
enable_read_iceberg_puffin_ndv
exists in source with default
true
but is undocumented;
enable_get_stats_from_external_metadata
I still cannot confirm exists; and whether 3.5.19 actually parses Spark-written Puffin sketches remains unverified — that still needs the empirical check.
i
@Rocky That answer contains several factual errors. Its advice to test your actual environment is sound, but several “could not confirm” points are directly established by the 3.5.19 source. Bot’s claim What the source establishes enable_get_stats_from_external_metadata could not be verified It exists in ConnectorProperties.java, and defaults to false for Iceberg. Enabling enable_iceberg_column_statistics alone is sufficient Insufficient when the catalog property is false. IcebergMetadata.java returns default statistics before reaching its column statistics reader. The accepted Puffin encoding could not be identified The 3.5.19 reader explicitly accepts APACHE_DATASKETCHES_THETA_V1, with one column field ID and an “ndv” property. Statistics precedence is only inferred from 4.1 MetadataMgr.java in 3.5.19 explicitly checks StarRocks-collected statistics first. Connector metadata is the fallback when those statistics are absent or all requested columns are unknown. The scheduler fix has no 3.5 backport Incorrect. PR #80342 was merged into branch-3.5 on 9 October 2026. The catalog property is also listed in the official Iceberg catalog documentation, so this is more than an undocumented source constant. StarRocks The Spark compatibility question has concrete evidence. Iceberg’s Spark writer produces precisely that blob type, column field ID and numeric “ndv” property. There is an additional nuance: this StarRocks reader obtains the scalar NDV from the registered blob metadata; it does not deserialize the sketch payload in this code path. The distinction between “Spark’s writer” and “Iceberg’s own writer” is misleading here—`compute_table_stats` is Iceberg’s Spark implementation. Two practical corrections matter: • Staleness does not itself select the metadata fallback. The selection condition checks whether statistics are unknown, not their update timestamp. Old but known StarRocks statistics can therefore retain precedence. • Metadata metrics are not “always available.” Collection settings and the metrics actually recorded in Iceberg files determine what StarRocks can obtain.For validation, disable query-triggered collection before inspecting or dropping competing statistics, since statistics lookups can themselves enqueue collection. Then test one controlled table and compare the Puffin NDV switch enabled versus disabled.
r
Corrections accepted — my earlier answers were wrong on five points I can't re-verify Java source lines with my tools (docs/vector search only), so I'm taking your source findings as authoritative. Two of them the docs independently confirm: •
enable_get_stats_from_external_metadata
is documented.
It's in the official Iceberg catalog docs: "Whether to obtain statistics from Iceberg metadata", default
false
, catalog property, v3.4+. My "could not verify this exists" was flatly wrong, and worse, I advised you not to set it — the one setting that is a hard prerequisite. The doc entry also states that when it's
true
, a session variable of the same name further controls which statistics type is collected. •
enable_iceberg_column_statistics
alone is insufficient
— consistent with the doc phrasing that the catalog property gates the whole metadata-statistics path ("Starting from v3.4, StarRocks can obtain statistics of Iceberg tables by reading Iceberg metadata through setting the following parameters"). The other three I accept on your evidence:
APACHE_DATASKETCHES_THETA_V1
+ single column field ID + numeric
ndv
property;
MetadataMgr
checking StarRocks-collected statistics first with connector metadata as fallback; and PR #80342 merged to
branch-3.5
on 2026-10-09 (my "no 3.5 backport" was wrong twice over — I'd also cited #80329 rather than #80342, so possibly a fix plus backport pair). One caveat I can't resolve: whether 3.5.19 specifically contains #80342 depends on that tag's cut date relative to 2026-10-09, which I don't have. Check the 3.5.19 release notes or
git tag --contains
on the commit before assuming the stall is fixed. Revised answers 1. Puffin NDV consumption — yes. The reader accepts
APACHE_DATASKETCHES_THETA_V1
blobs with one column field ID and an
ndv
property, and Iceberg's Spark
compute_table_stats
writer emits exactly that. Your "Spark writer vs Iceberg's own writer" distinction was the right correction:
compute_table_stats
is Iceberg's Spark implementation, so there's no compatibility gap to hypothesize about. Also note the reader reads the scalar NDV from registered blob metadata rather than deserializing the sketch — so what matters is that the
ndv
property is present and numeric, not sketch-payload compatibility. 2. Settings — all three are needed, at different scopes: Setting | Scope | Default | Role
enable_get_stats_from_external_metadata
| catalog property (
CREATE/ALTER CATALOG
) |
false
| Hard gate;
false
returns default stats before the column-statistics reader is reached
enable_get_stats_from_external_metadata
| session variable (same name) | — | Further selects which statistics type to collect
enable_iceberg_column_statistics
| session variable |
false
| Enables column stats incl. NDV from Puffin;
false
= row count only
enable_read_iceberg_puffin_ndv
| session variable |
true
| Toggles the Puffin NDV path So: catalog property plus
SET enable_iceberg_column_statistics = true
. Your set was right; my answer telling you to drop the catalog property was the thing that would have broken it. 3. Precedence — StarRocks-collected statistics win, and staleness is irrelevant. The selection checks whether statistics are unknown, not their timestamp. Old-but-known StarRocks statistics keep precedence indefinitely, so waiting for staleness never promotes the metadata path.
DROP STATS
is the only way to vacate the slot — I previously implied staleness might matter, which was wrong and would have made your test silently measure nothing.
4. Disabling
enable_query_trigger_analyze
— viable, with caveats.
Remaining limitations: histograms on external tables are Hive-only, so no skew/MCV info for Iceberg; multi-column joint NDV is manual-collection-only and I can't confirm external/Iceberg support; NDV is approximate. And disabling the trigger also stops the low-cardinality dictionary updates that share the scheduler — watch for plan regressions on low-cardinality columns. 5. Also correct: metadata metrics are not "always available." They depend on collection settings and on which metrics Iceberg actually recorded per column. If the table was written with metrics disabled (e.g.
write.metadata.metrics.default=none
), there is no min/max/null-count/NDV to read regardless of your StarRocks settings. Minimal validation procedure (revised ordering)
Copy code
sql
-- 0. FIRST: stop collection, or inspecting stats will enqueue more work
SET enable_query_trigger_analyze = false;

-- 1. Gate the catalog property
ALTER CATALOG lake SET ("enable_get_stats_from_external_metadata" = "true");

-- 2. Vacate StarRocks-collected stats (staleness alone won't do it)
SELECT * FROM _statistics_.external_column_statistics WHERE table_name = 'transactions';
DROP STATS lake.db.transactions;

-- 3. Enable column stats; leave the Puffin switch at default true
SET enable_iceberg_column_statistics = true;
SET enable_read_iceberg_puffin_ndv = true;

-- 4. Pick up the new statistics file
REFRESH EXTERNAL TABLE lake.db.transactions;
Then, on one controlled table: 1. In Spark, run
compute_table_stats
for
customer_id
, `account_id`; confirm a
statistics
entry was actually committed to the table metadata JSON. 2. In StarRocks, confirm the table's Iceberg column metrics exist (record count, per-column null counts, bounds). If not, stop — nothing will be consumed. 3.
EXPLAIN LOGICAL
a query whose estimate depends on NDV (group-by or join on
customer_id
). Record
Estimates: {row: ...}
. 4.
SET enable_read_iceberg_puffin_ndv = false;
and re-run the same
EXPLAIN
. The delta between steps 3 and 4 is your positive signal — it isolates the Puffin NDV contribution from min/max/row-count. No delta means the blob isn't being read (wrong field ID, missing
ndv
property, or stale metadata). 5. Do not use the profile's
StatsSource
label on 3.5.19 — it reports
NONE
for metadata-based Iceberg scans (PR #76560, no 3.5 backport). Still genuinely unverified The session-variable value semantics of
enable_get_stats_from_external_metadata
(docs say it selects statistics type, but I didn't retrieve its accepted values), and whether 3.5.19's tag contains #80342. Both are worth confirming against your build before rollout. References • data_source/catalog/iceberg/iceberg.md • sql-reference/System_variable.md • using_starrocks/Cost_based_optimizer.md • data_source/feature-support-data-lake-analytics.md References • administration/configuration/FE_parameters/user_query_loading.md • using_starrocks/Cost_based_optimizer.md • administration/configuration/FE_parameters/stats_storage.md • data_source/catalog/iceberg/iceberg.md • knowledge/qa/statistics_collection.md (StarRocks knowledge base) • sql-reference/System_variable.md