Skip to content

Commit 4766258

Browse files
committed
fix: optimize etag generation for principal activity
1 parent cb58817 commit 4766258

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/datastore/pg-store.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4487,10 +4487,27 @@ export class PgStore extends BasePgStore {
44874487
UNION
44884488
(
44894489
SELECT '0x' || encode(tx_id, 'hex') AS tx_id
4490-
FROM nft_events
4491-
WHERE (sender = ${principal} OR recipient = ${principal})
4492-
AND canonical = true
4493-
AND microblock_canonical = true
4490+
FROM (
4491+
(
4492+
SELECT tx_id, block_height, microblock_sequence, tx_index, event_index
4493+
FROM nft_events
4494+
WHERE sender = ${principal}
4495+
AND canonical = true
4496+
AND microblock_canonical = true
4497+
ORDER BY block_height DESC, microblock_sequence DESC, tx_index DESC, event_index DESC
4498+
LIMIT 1
4499+
)
4500+
UNION ALL
4501+
(
4502+
SELECT tx_id, block_height, microblock_sequence, tx_index, event_index
4503+
FROM nft_events
4504+
WHERE recipient = ${principal}
4505+
AND canonical = true
4506+
AND microblock_canonical = true
4507+
ORDER BY block_height DESC, microblock_sequence DESC, tx_index DESC, event_index DESC
4508+
LIMIT 1
4509+
)
4510+
) AS combined
44944511
ORDER BY block_height DESC, microblock_sequence DESC, tx_index DESC, event_index DESC
44954512
LIMIT 1
44964513
)

0 commit comments

Comments
 (0)