mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
fix abysmal postgresql performance in getSortedSetsMembers (#8030)
* refactor postgres upgrade function to use async * add function wrapper for getting the elements of a sorted set to avoid postgres planning the query with a nested sequential scan * fix fatal(?!) lint errors * add missing await * bump PostgreSQL version on Travis CI to one that isn't over 3 years out of date
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
b47f1769e4
commit
f65922297d
@@ -463,19 +463,14 @@ SELECT o."_key" k
|
||||
const res = await module.pool.query({
|
||||
name: 'getSortedSetsMembers',
|
||||
text: `
|
||||
SELECT o."_key" k,
|
||||
array_agg(z."value" ORDER BY z."score" ASC) m
|
||||
FROM "legacy_object_live" o
|
||||
INNER JOIN "legacy_zset" z
|
||||
ON o."_key" = z."_key"
|
||||
AND o."type" = z."type"
|
||||
WHERE o."_key" = ANY($1::TEXT[])
|
||||
GROUP BY o."_key"`,
|
||||
SELECT "_key" k,
|
||||
"nodebb_get_sorted_set_members"("_key") m
|
||||
FROM UNNEST($1::TEXT[]) "_key";`,
|
||||
values: [keys],
|
||||
});
|
||||
|
||||
return keys.map(function (k) {
|
||||
return (res.rows.find(r => r.k === k) || { m: [] }).m;
|
||||
return (res.rows.find(r => r.k === k) || {}).m || [];
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user