loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf: avoid sorting team names for `ComposeMetas` (#7223)

- `ComposeMetas` is called to compose meta information for the markdown processer (which is called a lot), one of those information is the team names that have access to the repository. This is used to decide if a mention is a team mention or not.
- The SQL query sorts the names, this is unnecessary and not required for within the processer; it does a simple `strings.Contains(teams, ","+teamName+",")`, which doesn't rely on sorted values.
- Doing the SQL query with sorting against Codeberg's MariaDB took ~0.180s and without sorting took ~0.03s. Although the returned values are often a few rows (the query I tested returned 8 values) it seems that doing any sorting will create an temporary index and is mainly optimized where it has to sort a huge amount of rows.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7223
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>

authored by

Gusted
Gusted
and committed by
Earl Warren
511148db 5e338062

-1
-1
models/repo/repo.go
··· 529 529 Join("INNER", "team", "team.id = team_repo.team_id"). 530 530 Where("team_repo.repo_id = ?", repo.ID). 531 531 Select("team.lower_name"). 532 - OrderBy("team.lower_name"). 533 532 Find(&teams) 534 533 metas["teams"] = "," + strings.Join(teams, ",") + "," 535 534 metas["org"] = strings.ToLower(repo.OwnerName)