Is there a way to filter the second column with a starts_with or a contains? To demonstrate the sentiment of what I’d like to do (in spite of it not being a valid guard clause):
binary_part is allowed in matchspecs, so in principle you could use that for the starts_with search. That won’t help with contains, though…
While it’s faster than many other approaches :ets.select is still going to be time-consuming if the table is large; it’s like always doing a sequential-scan in a full-size DBMS.
The solution to that for ETS is similarly parallel: create additional tables that speed up important queries. For instance, you can make “starts with” queries efficient if you maintain a second :bag table like: