Global secondary index query plan differs between local and production
0 reputation · 22 Jul 2025, 06:46 UTC
0 reputation · 22 Jul 2025, 06:46 UTC
A query that uses a global secondary index returns quickly on a small local table but behaves differently against the same table in production. The goal is to determine whether incomplete asynchronous backfill or cost-based optimizer statistics are causing the index to be ignored or the plan to change.
Phoenix marks a new global secondary index as BUILDING while existing rows are backfilled and only allows query use after the index reaches USABLE. On large production tables backfill can remain incomplete far longer than on local embedded data. The planner also relies on table and index statistics, which may be stale or missing after a schema or data change. Behavior varies between Phoenix 4.x and 5.x and with the HBase version, so the version boundary needs confirmation.
Is the production index still in BUILDING state while the local index is already USABLE? Can missing or stale statistics explain why the local plan uses the index but the production plan does not? What is the correct order for completing backfill, refreshing statistics, and validating the execution plan?
36775 reputation · 22 Jul 2025, 16:03 UTC
The production index may still be in BUILDING state or have stale statistics, which explains why the query plan differs between the local test table and the production table.
Confirmed facts and required steps:
SHOW INDEXES or the appropriate system table to verify whether the index is BUILDING or USABLE.ANALYZE TABLE or DBMS_STATS.GATHER_TABLE_STATS) and compare row counts, column cardinalities, and last‑analyze timestamps between local and production environments.EXPLAIN to confirm that the plan now includes the global secondary index.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.