Phoenix global secondary index write amplification versus read latency at sparse write volume
0 reputation · 24 Jun 2022, 17:21 UTC
0 reputation · 24 Jun 2022, 17:21 UTC
A Phoenix 5.x table on HBase 2.x serves a read-heavy, low-traffic workload with fewer than one write per second. The goal is to decide whether adding a global secondary index on high-selectivity columns lowers read latency enough to justify the extra index-table writes on the update path.
Phoenix global indexes support covered queries that avoid full table scans, but each write also updates the index table, increasing write-path RPCs and potential tail latency on shared clusters. No documented threshold defines when this amplification outweighs read gains at very low write rates, and stale optimizer statistics may further skew plan choice.
Version assumption: Phoenix 5.x with HBase 2.x and cost-based optimizer statistics enabled. The write rate, schema, and access pattern must be treated as variables because the trade-off has no published heuristic.
At what write volume does global-index write amplification exceed read-latency benefits for covered queries? Which table and index characteristics should be compared before adding the index? How can read latency and write amplification be isolated without changing production traffic?
36775 reputation · 24 Jun 2022, 20:51 UTC
At <=1 write/sec, Phoenix GSI write amplification and read-latency gains from covered queries interact in ways that depend on index design and optimizer state. The following answers address the three points raised.
Write-volume threshold: No published heuristic defines the exact write rate where amplification outweighs read benefits at sparse volumes. At <=1 write/sec, amplification is driven by RPC round-trips and sequential log/memstore flushes on each index tablet. Read-latency improvements can still dominate when index selectivity is high and cost-based optimizer statistics are fresh; stale statistics may cause the planner to favor a full table scan, negating gains.
Characteristics to compare: index column selectivity and cardinality, index stored-column width beyond the row key, base-table region count and scan cost, optimizer statistic freshness and last ANALYZE timestamp, region-server locality and hotspot risk for the index tablet, compaction impact on index storefile size, and the update pattern (whether writes touch indexed columns exclusively or mix non-indexed columns).
Isolation without production impact: clone the table to a test cluster; run a controlled 1 write/sec upsert workload while capturing Phoenix metrics (write_rpcs) and HBase region-server latency. Execute EXPLAIN on the covered query with and without fresh column statistics. Measure read latency percentiles (p50, p99) with the index enabled versus a forced full table scan (optimizer hint). Monitor HBase compaction metrics (time, storefile size) on the index tablet during the test.
To refine the recommendation, it would help to know the last ANALYZE timestamp for the indexed column(s). Stale statistics can cause the cost-based optimizer to favor a full table scan, inverting the expected latency benefit.
Use comments to ask for clarification. Post a solution as an answer.
36,775 reputation · 25 Jun 2022, 00:48 UTC
On Phoenix 5.x with HBase 2.x, sub-one-write-per-second volume keeps absolute global-index write amplification small, but the extra index-table put still adds WAL, MemStore, flush, and compaction pressure on shared region servers. That can inflate write tail latency even when average throughput looks negligible.
Before adding the index, run EXPLAIN on representative queries with and without the index, and refresh statistics with ANALYZE first. A covered query must reference only indexed columns; otherwise Phoenix falls back to the base table and the read gain disappears. Test on a snapshot clone rather than production traffic, comparing p95/p99 read and write latency with the index present and absent.