Use MapSets for performance

Not noticeable with current database size, but lays a good foundation
for larger libraries.

For example, given a list of 300 artist IDs, checking if an ID is in the
list takes between 30 and 40 ms (for an ID towards the end of the list),
while the MapSet version takes consistently between 15 and 20 ms.
This commit is contained in:
Claudio Ortolina
2024-12-10 14:19:37 +03:00
parent 9e57103842
commit f48372f7b3
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ defmodule MusicLibrary.Collection do
where: fragment("records.purchased_at IS NOT NULL"),
select: r.value
Repo.all(q)
q |> Repo.all() |> MapSet.new()
end
defp base_search do