Index records by type to improve query perf

This commit is contained in:
Claudio Ortolina
2024-11-23 23:16:24 +00:00
parent 93b347ad8d
commit b2e1f1f8d1
2 changed files with 10 additions and 3 deletions
@@ -0,0 +1,7 @@
defmodule MusicLibrary.Repo.Migrations.AddTypeIndexToRecords do
use Ecto.Migration
def change do
create index("records", [:type])
end
end
+3 -3
View File
@@ -37,7 +37,7 @@ defmodule MusicLibrary.CollectionTest do
setup [:fill_collection]
test "returns the count of matching records, excluding wishlisted records" do
assert 2 = Collection.search_records_count("brave")
assert 2 == Collection.search_records_count("brave")
end
end
@@ -45,7 +45,7 @@ defmodule MusicLibrary.CollectionTest do
setup [:fill_collection]
test "returns the count of records in the collection by format, excluding wishlisted records" do
assert [vinyl: 2, cd: 1] = Collection.count_records_by_format()
assert [vinyl: 2, cd: 1] == Collection.count_records_by_format()
end
end
@@ -53,7 +53,7 @@ defmodule MusicLibrary.CollectionTest do
setup [:fill_collection]
test "returns the count of records in the collection by type, excluding wishlisted records" do
assert [live: 1, ep: 1, album: 1] = Collection.count_records_by_type()
assert [album: 1, ep: 1, live: 1] == Collection.count_records_by_type()
end
end