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 1de97b1
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ 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 = "Task"
AND a.resourceUuid IN (
SELECT resourceUuid FROM DateTimeIndexEntity
WHERE resourceType = '${classType.newInstance().resourceType}' AND index_name = '_lastUpdated' AND index_to >= ?
WHERE resourceType = "Task" AND index_name = "_lastUpdated" AND index_to >= 0
)
AND (b.index_name = '_lastUpdated' OR c.index_name = '_lastUpdated')
ORDER BY c.index_from ASC, a.id ASC
LIMIT ? OFFSET ?
ORDER BY b.index_from ASC, c.index_from ASC
LIMIT 25 OFFSET 0
""".trimIndent(),
listOf(lastRecordUpdatedAt, batchSize, offset)
)
Expand Down

0 comments on commit 1de97b1

Please sign in to comment.