Duczer East
Healthcare

In-perimeter AI on governed clinical and operational data.

Financial Services

Private AI and data platforms built to clear model-risk and audit review.

Financial services

Private AI, KYC/AML, API gateways and data governance for banks.

Insurance

Change data capture, governed agents and integration for insurers.

Healthcare

PHI document intelligence, FHIR APIs and in-perimeter AI for health systems and plans.

GuideCloudera / Data Services & AI7 min read

Apache Phoenix on HBase: when to use it, secondary indexes, limits and tuning

SQL for applications on top of HBase, with a price per index

Authored byCo-Founder and Managing Partner, Duczer East
Part of the Insights topic: Private AI & Data Architecture
On this page
  1. Why Phoenix
  2. The primary key is the row key
  3. Secondary indexes
  4. Index consistency and write cost
  5. Limits
  6. Salting and hotspots
  7. Connecting applications
  8. Tuning
  9. Questions we hear
  10. A first engagement

Apache Phoenix gives HBase tables a SQL interface, so application developers can use standard SQL, secondary indexes and views instead of the native API. It suits low-latency application queries, not large analytical scans. Every secondary index costs a write per row change, so add them only for queries you have proven.

Why Phoenix

Cloudera describes Operational Database as powered by HBase and Phoenix. HBase gives real-time random access by key. Phoenix adds ANSI-style SQL, so teams can work in tables, columns and queries. Developers can also keep using HBase's native APIs where they need them, with one firm exception: Cloudera states that changing a Phoenix table through the HBase native API is not supported, and it can cause errors, inconsistent indexes, wrong results or data corruption. Pick one write path per table.

The Apache Phoenix tuning guide sets the expectation. Phoenix and HBase work well for point lookups and small range scans, and if your application needs many full table scans, they are likely not the right tool. Use Parquet-based tools for those reads.

The primary key is the row key

Phoenix joins your primary key columns into the HBase row key, and the guide calls this the single most important factor in performance. You cannot change it later without rewriting the data and index tables. The leading column has the most effect, so lead with the column you filter on most in your most important queries. Every cell carries a copy of the row key, so keep key columns compact. This is why the HBase row-key work in Apache HBase on Cloudera comes first.

Secondary indexes

Without an index, a query on a column that is not part of the row key scans the table. A secondary index lets Phoenix find rows by another column. Phoenix has global and local indexes, and an index can include extra columns so a query is answered from the index alone.

Index typeBest forCost
Global indexRead-heavy tables, queries on a non-key columnExtra write across servers for each change
Local indexWrite-heavy tables where the index sits beside the dataReads may touch more regions
Covered index (with included columns)Queries that need only a few columnsLarger index, more write cost
Uncovered indexWide or rarely read columns that you do not want copied into the indexA server-side join back to the data row at read time

The Apache documentation adds detail. With a global index, all the performance penalty lands at write time, and at read time Phoenix scans the index like any HBase table. A global index is not used for a query that references a column outside it, unless you use an uncovered index. A local index keeps data and index together on one server, so writes avoid network cost, but every region must be checked at read time. Phoenix also supports functional indexes on expressions, such as UPPER of a name, for case-insensitive search.

sql
-- Covered global index: answers the query from the index alone
CREATE INDEX orders_by_customer ON orders (customer_id, order_date) INCLUDE (status);

-- Local index
CREATE LOCAL INDEX orders_by_status ON orders (status);

-- Check which access path a query uses
EXPLAIN SELECT status FROM orders WHERE customer_id = 'C1001';

Confirm index behavior and settings for your Runtime release, including whether uncovered and eventually consistent indexes exist in the Phoenix version you run.

Index consistency and write cost

Phoenix documents that after a successful commit, data is written to the table and all its indexes. What differs is how safe the pair is if a server crashes mid-commit:

  • Local indexes are always consistent from Phoenix 4.8 on.
  • Global indexes on transactional tables give the strongest guarantee, with atomic commits, at the cost of conflict detection and running a transaction manager.
  • For mutable and immutable tables created on current versions, Phoenix uses a three-phase write with a status on index rows, so unverified rows are repaired from the data table at read time.
  • For write-heavy tables that can accept a short staleness window, a global index can be created as eventually consistent to move its upkeep off the write path.

If your rows are written once and never updated, such as events, declare the table with IMMUTABLE_ROWS=true to cut write cost. Nothing enforces it, so if the data does change, the index drifts from the table. To build an index on a large existing table, use the ASYNC keyword so a batch job builds it instead of the foreground statement.

Limits

  • It is not built for large scans or heavy joins. Move analytics to Impala on Kudu or Iceberg.
  • Index maintenance adds write latency.
  • Keep a close eye on how rows are salted and keyed, because Phoenix sits on the HBase key design.
  • Salted tables return rows in salt order, not natural key order, unless you turn on the row-key ordered setting, which costs a client-side merge.

Salting and hotspots

For monotonically increasing keys, such as a timestamp or sequence, Phoenix can salt the row key with the SALT_BUCKETS table property, from 1 to 256. The tuning guide says to set buckets close to the number of region servers, and not to salt by habit: use salting only when you see hotspotting, because it makes range reads query several buckets. A salted table with no split points is pre-split on salt boundaries.

sql
CREATE TABLE events (
  event_id BIGINT NOT NULL,
  device_id VARCHAR,
  payload VARCHAR,
  CONSTRAINT pk PRIMARY KEY (event_id)
) SALT_BUCKETS = 12, IMMUTABLE_ROWS = true;

The bucket count above is a placeholder: set yours from the number of region servers on your cluster.

Connecting applications

Cloudera documents two JDBC drivers. The thick driver talks to HBase directly, so the client needs network access to all HBase nodes and the cluster's hbase-site.xml. The thin driver talks to Phoenix Query Server, which needs only access to that server, and it can go direct or through Apache Knox over HTTPS. Users also need Ranger permission for Phoenix and HBase. For apps outside the cluster network, the thin driver is usually the simpler path to approve.

Tuning

  1. Start from your five most important queries and read their explain plans.
  2. Add one index at a time and measure the write cost.
  3. Salt tables with sequential keys to spread load, but only if you see hotspots.
  4. Keep column families few.
  5. Declare append-only tables immutable.
  6. Re-test after upgrades.

Questions we hear

Can Phoenix replace our data warehouse? No. It serves application queries by key and small range. Warehouse scans belong on Impala.

How many indexes is too many? Each index is another table written on every change. Add one only when a proven query needs it.

The storage side is covered in Apache HBase on Cloudera, and the service view on the Operational Database page. For choosing a SQL engine for analytics, see Impala vs Hive.

A first engagement

Duczer East offers a Phoenix query and index review: we take your top queries, read their plans, test each index candidate for write cost and hand back a short list of indexes to add, keep or drop.

Frequently asked questions

What is Apache Phoenix?

A SQL layer over Apache HBase. Applications can query HBase tables with standard SQL instead of the native API.

Do I need Phoenix to use HBase?

No. You can use the HBase native APIs. Phoenix helps when developers want SQL, joins on small tables, secondary indexes and views.

Do secondary indexes slow writes?

Yes. Each index adds a write for every row change, so add them for queries you have proven you need.

Is Phoenix a data warehouse?

No. It suits low-latency application queries. For large analytical scans use Impala on Kudu or Iceberg tables.

What is the difference between global and local Phoenix indexes?

Global indexes suit read-heavy use, with the cost paid at write time. Local indexes keep index data beside table data for write-heavy use, but reads must check every region.

When should we salt a Phoenix table?

Only when you see hotspotting from monotonically increasing keys. Salting spreads writes but makes range reads query several buckets.

Which JDBC driver should applications use?

The thick driver needs access to all HBase nodes. The thin driver needs only Phoenix Query Server, directly or through Knox over HTTPS, which is easier to approve for outside networks.

Authored by

Co-Founder and Managing Partner, Duczer East

David deBoisblanc is co-founder of Duczer East and a digital transformation and innovation leader in data-centric AI, agentic systems, and enterprise integration. He shapes intent-driven AI solutions that modernize how organizations use data, drawing on deep experience with Cloudera and complex enterprise integration landscapes.

Newsletter

The Practitioner's Briefing

Senior-level insights on agentic AI, data engineering and enterprise integration, delivered to your inbox.

One email when there is something worth reading. Unsubscribe any time.

Let's Talk

Want to discuss the ideas raised here?

Tell us what you are working on. A senior practitioner replies, and only your email is required.

Get a quote