The limitation of List

I gonna implement a system that collect a lot of data in List on GenServer process. Want to know how much limit it can grow. Performance of searching.

1 Like

Searching in a linked list grows linear with the number of elements in the list. So if you double the length of the list it will take twice as long as before to find that a given element is not in the list.

Of course you can reduce lookup time if you use an ordered list, but that will increase insertion.

If you have unique keys, I’d go for a map. If you need to preserve order you might want to add some extended data to each key, which does indicate its age.

2 Likes

I need to match a partial of key, like a rule-based matching. Right now when I do a matching, I scan though all the list to find a bunch of best match. That’s I start to feel a problem.

If the part you are matchin on, is always from the beginning, you can probably implement a trie based storage.