Hello,
I’m trying to understand how to handle filtering and pagination efficiently and maintainably using the actor model.
For example, if I wanted to build an Amazon clone on ICC, using an index canister managing product creation and assigning each new product to a bucket, there will eventually come a point where I may have millions of buckets containing millions of products.
Now I want to introduce a filtering system:
-
I want to retrieve products ordered by price
-
I want to retrieve products ordered by price and buyer notes
On a traditional database, I would simply use something like: LIMIT x OFFSET y ORDER BY price ASC
But on the IC, there’s no centralized store. The only approach I can think of is to create an ordered index canister by price, which would itself manage many buckets storing an ordered list of all products by price. This means that whenever a product’s price changes, I might need to rearrange data across buckets to avoid exceeding the stable memory limit, especially if many products share the same price range.
When multiple filters are involved, the problem becomes even worse. It feels like an unmaintainable mess for every combination of filters I might want to support, and an enormous amount of work to replicate something trivial in Web2.
So my main question is: What’s the best way to handle this on the IC? I feel like I’m missing something fundamental.
Additional questions:
-
Can candb help manage this in a performant way?
-
Could the upcoming roadmap item, “Immutable Blob Storage Service for ICP,” help? (e.g., storing an ordered map by price in a blob and using it as a central store, possibly even with SQLite, to at least eliminate bucket management complexity)