Skip to content

Commit

Permalink
Change p2p fetch records query to fix slowness
Browse files Browse the repository at this point in the history
Fixes #2536
  • Loading branch information
ekigamba committed Jul 7, 2023
1 parent 045d3da commit 4d2deaa
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ constructor(
SELECT a.serializedResource
FROM ResourceEntity a
LEFT JOIN DateIndexEntity b
ON a.resourceType = b.resourceType AND a.resourceUuid = b.resourceUuid
ON a.resourceType = b.resourceType AND a.resourceUuid = b.resourceUuid AND b.index_name = "_lastUpdated"
LEFT JOIN DateTimeIndexEntity c
ON a.resourceType = c.resourceType AND a.resourceUuid = c.resourceUuid
WHERE a.resourceUuid IN (
ON a.resourceType = c.resourceType AND a.resourceUuid = c.resourceUuid AND c.index_name = "_lastUpdated"
WHERE a.resourceType = "${classType.newInstance().resourceType}"
AND a.resourceUuid IN (
SELECT resourceUuid FROM DateTimeIndexEntity
WHERE resourceType = '${classType.newInstance().resourceType}' AND index_name = '_lastUpdated' AND index_to >= ?
WHERE resourceType = "${classType.newInstance().resourceType}" AND index_name = "_lastUpdated" AND index_to >= ?
)
AND (b.index_name = '_lastUpdated' OR c.index_name = '_lastUpdated')
ORDER BY c.index_from ASC, a.id ASC
ORDER BY b.index_from ASC, c.index_from ASC
LIMIT ? OFFSET ?
""".trimIndent(),
listOf(lastRecordUpdatedAt, batchSize, offset)
Expand Down

0 comments on commit 4d2deaa

Please sign in to comment.