Database / Apache Cassandra Intermediate and Advanced interview questions
What is the ALLOW FILTERING clause and why is it risky?
Cassandra normally rejects queries that would require scanning data across partitions inefficiently — for example, filtering on a non-indexed, non-key column. ALLOW FILTERING overrides that safety check and lets the query run anyway.
SELECT * FROM orders WHERE amount > 1000 ALLOW FILTERING; -- runs, but may scan a large amount of data server-side to find matches
- Without
ALLOW FILTERING, Cassandra simply refuses queries it predicts will be inefficient, forcing the developer to reconsider the data model or add an index. - With it, the coordinator (and replicas) may scan far more data than the number of rows actually returned, since filtering happens after data is read rather than through an index lookup.
- On a small table or a query already scoped to one partition, the impact can be negligible; on a large, unbounded table it can mean scanning gigabytes of data for a handful of matching rows.
It's fine for ad-hoc analysis, debugging, or genuinely small reference tables, but it should almost never appear in an application's hot query path in production — a properly modeled query table or materialized view is the correct long-term fix.
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...
