Skip to content

Commit dde3318

Browse files
committed
Try reversing hash ordering
1 parent 54afed3 commit dde3318

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

src/Share/Web/UCM/SyncStream/Queries.hs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,24 +312,37 @@ allSerializedDependenciesOfCausalCursor cid = do
312312
JOIN types typ ON atc.component_hash_id = typ.component_hash_id
313313
JOIN type_local_component_references ref ON typ.id = ref.type_id
314314
)
315-
) SELECT bytes.bytes, tc.causal_hash
316-
FROM transitive_causals tc
317-
JOIN serialized_causals sc ON tc.causal_id = sc.causal_id
315+
)
316+
(SELECT bytes.bytes, ch.base32
317+
FROM transitive_components tc
318+
JOIN serialized_components sc ON tc.component_hash_id = sc.component_hash_id
318319
JOIN bytes ON sc.bytes_id = bytes.id
320+
JOIN component_hashes ch ON tc.component_hash_id = ch.id
321+
-- Reverse the ordering so deeper components come first
322+
ORDER BY row_number() OVER () DESC
323+
)
319324
UNION ALL
320-
SELECT bytes.bytes, an.namespace_hash
321-
FROM all_namespaces an
322-
JOIN serialized_namespaces sn ON an.namespace_hash_id = sn.namespace_hash_id
323-
JOIN bytes ON sn.bytes_id = bytes.id
324-
UNION ALL
325-
SELECT bytes.bytes, ap.patch_hash
325+
(SELECT bytes.bytes, ap.patch_hash
326326
FROM all_patches ap
327327
JOIN serialized_patches sp ON ap.patch_id = sp.patch_id
328328
JOIN bytes ON sp.bytes_id = bytes.id
329+
-- Reverse the ordering so deeper components come first
330+
ORDER BY row_number() OVER () DESC
331+
)
329332
UNION ALL
330-
SELECT bytes.bytes, ch.base32
331-
FROM transitive_components tc
332-
JOIN serialized_components sc ON tc.component_hash_id = sc.component_hash_id
333+
(SELECT bytes.bytes, an.namespace_hash
334+
FROM all_namespaces an
335+
JOIN serialized_namespaces sn ON an.namespace_hash_id = sn.namespace_hash_id
336+
JOIN bytes ON sn.bytes_id = bytes.id
337+
-- Reverse the ordering so deeper components come first
338+
ORDER BY row_number() OVER () DESC
339+
)
340+
UNION ALL
341+
(SELECT bytes.bytes, tc.causal_hash
342+
FROM transitive_causals tc
343+
JOIN serialized_causals sc ON tc.causal_id = sc.causal_id
333344
JOIN bytes ON sc.bytes_id = bytes.id
334-
JOIN component_hashes ch ON tc.component_hash_id = ch.id
345+
-- Reverse the ordering so deeper components come first
346+
ORDER BY row_number() OVER () DESC
347+
)
335348
|]

0 commit comments

Comments
 (0)