Database / Apache Cassandra Intermediate and Advanced interview questions
What is the difference between a secondary index and a materialized view?
Both let you query on something other than the base table's partition key, but they solve the problem in very different ways.
| Secondary Index | Materialized View |
| Indexes an existing column in place on the base table. | Creates a separate physical table with its own partition key. |
| Query still fans out across nodes at read time. | Query hits a single partition directly, like any normal table. |
| Cheap to create, no extra storage for a new table. | Uses extra storage and write bandwidth to maintain the copy. |
| Best for occasional, low-traffic lookups. | Best for well-defined, frequent query patterns. |
In practice, a secondary index is a quick, low-commitment way to support an ad-hoc query, while a materialized view (or its hand-rolled equivalent, a manually maintained query table) is the right tool when a query pattern is a core, high-traffic part of the application and needs single-partition read performance.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
