Menu

1 / 2

Your data has 10 attributes. How many indexes do you need to search within millisecond?

DEV Community: database·Anuj Kapoor·2 days ago
#DRAC6sKN
#devtodatabase#devto#dev#node#const
Reading 0:00
15s threshold

Every field you add to a filter panel doubles the combinations users can pick. If your fast path is an exact key lookup, that means one key per combination. Databases avoid this by combining per-field indexes at query time.

This tutorial shows how to do that in-process with a numbered tree, and you'll build the core trick yourself.

Same wall, two companies

I first hit this problem at a global travel company, and again at a global

e-commerce company. Records carried many attributes, every new feature asked

for a different combination of them, and answers had to fit inside a

user-facing request. Both times, the fast path was an in-memory key-value

lookup: superb when you know the exact key, awkward when the key is whatever

combination a user just picked.

How many indexes do 1,023 combinations need?

With n filter fields, users can pick 2^n - 1 nonempty combinations.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.