You've already forked AstralRinth
forked from didirus/AstralRinth
Fix random_projects route not returning the requested number of projects (#3758)
* Fix random_projects route not returning the requested number of projects * fix(labrinth): further improve random project route SQL query * chore: fix typo in comment * tweak(labrinth): more apparent and fast randomness for `random_projects_get` * tweak(labrinth): even better random projects query * chore: address formatting review --------- Co-authored-by: Alejandro González <me@alegon.dev>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- This index substantially brings down the cost of the query plan for the
|
||||
-- hot query at `labrinth::routes::v3::projects::random_projects_get`, from
|
||||
-- 354.04..363.39 to 171.33..180.68 (~2x improvement).
|
||||
--
|
||||
-- The numbers above were calculated in a clean PostgreSQL 17.5.0 container
|
||||
-- with 10k mods created with the SQL below.
|
||||
--
|
||||
-- WITH seq AS (SELECT n FROM GENERATE_SERIES(1, 10000) AS n)
|
||||
-- INSERT INTO mods (id, team_id, name, summary, icon_url, license_url, slug, status)
|
||||
-- SELECT n, 1, n, '', '', '', n, (ARRAY['approved', 'pending'])[n % 2 + 1] from seq;
|
||||
|
||||
CREATE INDEX mods_status ON mods(status);
|
||||
Reference in New Issue
Block a user