Support Questions

Find answers, ask questions, and share your expertise

Phoenix secondary index with all data table columns

Explorer

If I create a secondary index on data table and include all the columns in it, then the index does not get picked up for any query. This is evident from explain plan of the query such as count(*) or an inner join query. Is that because phoenix optimizer figures that having all the columns in index does not add value over doing a self join with main table for the inner join query? In that sense, is it a bad practice to add all columns to secondary index?

Just to state further, my data table has 2million rows.

2 REPLIES 2

"Is that because phoenix optimizer figures that having all the columns in index does not add value over doing a self join with main table for the inner join query" -- Correct. A count(*) query would have to read the entire table. There's no point in using the index table for this.

"In that sense, is it a bad practice to add all columns to secondary index?" -- Yes, you should only add columns to an index that are commonly used together. Adding all columns to a secondary index is pointless.

Explorer

Thank you @Josh Elser - This is in line with my understanding. It would be a fair statement to make that phoenix indexes are not like traditional indexes which derive main benefit from remaining in-memory. Phoenix indexes are just another Hbase table allowing an orthogonal lookup on the columns (by copying them).

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.