mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-26 18:27:09 +01:00
perf(pglite): filter artist roles by jsonb containment
After the post-scan ANALYZE the planner probed library_artist once per
artist for the role filter written as stats->'role'->>'m' IS NOT NULL:
29,602 lookups at 3.8 ms each, 116 s for the artist list on roy. The
containment form (stats @> '{"role": {}}') is served by the GIN index:
0.2 s for the same list.
This commit is contained in:
parent
1818f4395b
commit
943beae278
1 changed files with 2 additions and 1 deletions
|
|
@ -163,7 +163,8 @@ func NewArtistRepository(ctx context.Context, db dbx.Builder) model.ArtistReposi
|
|||
func roleFilter(_ string, role any) Sqlizer {
|
||||
if role, ok := role.(string); ok {
|
||||
if _, ok := model.AllRoles[role]; ok {
|
||||
return Expr("library_artist.stats->'" + role + "'->>'m' IS NOT NULL")
|
||||
// Containment is served by the GIN index on stats; the ->> form forces a row-by-row probe.
|
||||
return Expr("library_artist.stats @> ?::jsonb", `{"`+role+`": {}}`)
|
||||
}
|
||||
}
|
||||
return Eq{"1": 2}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue