Skip to content

Commit 28a86f5

Browse files
authored
Fixing performance regression in all_resource_timestamps for postgres (#3631)
1 parent 65e4b0b commit 28a86f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kinto/core/storage/postgresql/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ def all_resources_timestamps(self, resource_name):
252252
WITH existing_timestamps AS (
253253
-- Timestamp of latest object by parent_id.
254254
(
255-
SELECT DISTINCT ON (parent_id) parent_id, last_modified
255+
SELECT parent_id, MAX(last_modified) AS last_modified
256256
FROM objects
257257
WHERE resource_name = :resource_name
258-
ORDER BY parent_id, last_modified DESC
258+
GROUP BY parent_id
259259
)
260260
-- Timestamp of resources without sub-objects.
261261
UNION ALL

0 commit comments

Comments
 (0)