Push the channel_keys membership into the blob read query
What does this MR do and why?
Since !251344 (merged), Workflow#reconstructed_channel_values filters the reconstructed channel_values down to the checkpoint header's channel_keys (the "membership"). It does this in Ruby, after the blob query runs. The query fetches every channel ever blobbed on the ancestor chain, then #select_live_channels drops the dead ones after decoding. For chat workflows, that means fetching and decompressing every dead branch:to:* routing channel only to throw it away.
Kibana p95 db_duration_s for getLatestCheckpoint (the gateway resume payload) is 0.107s on the legacy read, vs 0.339s on blob reads. The issue guessed that most of that gap was TOAST reads for dead channels the membership filter discards. Measurement on a production workflow (Database Lab, plans in the Database section below) shows those dead routing blobs are tiny. The filter's actual win is fetching and zlib-decoding fewer rows in Ruby — 15% of rows on the sampled workflow — plus skipping the blob query entirely when a header declares an empty membership.
This MR pushes the membership into the SQL:
#reconstructed_channel_valuesdefaults thechannels:blob-query filter to the header'schannel_keys. An explicitchannels:argument now intersects with the membership instead of bypassing it.#blobs_by_thread_ts_for(the batched page read used by the internal checkpoints API) filters by the union of the page headers'channel_keys. One membership-less header on the page disables the filter, since its fold may need any channel.- A NULL membership (a header written before
channel_keysexisted, or a legacy checkpoint row) keeps today's unfiltered read. #select_live_channelsstays as the post-fold correctness guard. The query filter is only an optimization.
The filter is served by the existing dedup index idx_duo_wf_checkpoint_blobs_dedup on (project_id, workflow_id, thread_ts, channel, ...). No schema change.
The fold in ChannelValuesReconstructor is strictly per-channel (blobs are grouped by channel before any anchoring/dedup), so removing other channels' blobs can't change a surviving channel's value.
No behavior change to returned values, only fewer rows fetched and decompressed. Specs pin: membership pushed into the query, intersection with an explicit channels:, NULL membership stays unfiltered, and the batched read's union filter plus its NULL-disable case.
Database
Before:
SELECT "p_duo_workflows_checkpoint_blobs".* FROM "p_duo_workflows_checkpoint_blobs" WHERE "p_duo_workflows_checkpoint_blobs"."workflow_id" = 12345 AND "p_duo_workflows_checkpoint_blobs"."workflow_created_at" = '2026-08-01 00:00:00' AND "p_duo_workflows_checkpoint_blobs"."project_id" = 278964 AND "p_duo_workflows_checkpoint_blobs"."thread_ts" IN ('ts-1', 'ts-2', 'ts-3') ORDER BY "p_duo_workflows_checkpoint_blobs"."id" ASCAfter (only change: the added channel IN filter):
SELECT "p_duo_workflows_checkpoint_blobs".* FROM "p_duo_workflows_checkpoint_blobs" WHERE "p_duo_workflows_checkpoint_blobs"."workflow_id" = 12345 AND "p_duo_workflows_checkpoint_blobs"."workflow_created_at" = '2026-08-01 00:00:00' AND "p_duo_workflows_checkpoint_blobs"."project_id" = 278964 AND "p_duo_workflows_checkpoint_blobs"."thread_ts" IN ('ts-1', 'ts-2', 'ts-3') AND "p_duo_workflows_checkpoint_blobs"."channel" IN ('ui_chat_log', 'status', 'conversation_history') ORDER BY "p_duo_workflows_checkpoint_blobs"."id" ASCQuery plans (production, Database Lab)
The plans below come from Database Lab (postgres.ai), run against a production clone on a real chat workflow: id 6606126, a 107-checkpoint ancestor chain, and 350 blobs across 8 channels. Its latest header's channel_keys lists 6 live channels, so the filter excludes __start__ and the dead branch:to:developer_agent#agent routing channel — 54 of the 350 rows. Both plan pairs ran warm. A cold run of the before query took 78 ms with 153 buffer reads, all of it I/O.
Plan pair for the query as the code runs it (SELECT *)
Before:
Sort (cost=218.54..218.55 rows=1 width=404) (actual time=0.519..0.533 rows=350 loops=1)
Sort Key: p_duo_workflows_checkpoint_blobs.id
Sort Method: quicksort Memory: 182kB
Buffers: shared hit=159
I/O Timings: read=0.000 write=0.000
-> Index Scan using p_duo_workflows_checkpoint_blobs_20260825_workflow_id_idx on gitlab_partitions_dynamic.p_duo_workflows_checkpoint_blobs_20260825 p_duo_workflows_checkpoint_blobs (cost=0.70..218.53 rows=1 width=404) (actual time=0.040..0.382 rows=350 loops=1)
Index Cond: (p_duo_workflows_checkpoint_blobs.workflow_id = 6606126)
Filter: ((p_duo_workflows_checkpoint_blobs.workflow_created_at = '2026-08-25 07:33:39.179202+00'::timestamp with time zone) AND (p_duo_workflows_checkpoint_blobs.project_id = 14022) AND (p_duo_workflows_checkpoint_blobs.thread_ts = ANY ('{1f1a0581-1af4-6c00-8069-de041748e6f2,1f1a0581-06a5-6669-8068-071efa25ea3f,1f1a0580-f56f-68af-8067-356957e25d62,1f1a0580-db37-6abb-8066-ddd686288b94,1f1a0580-ce03-642f-8065-7441015e4ef6,1f1a0580-acd0-6c43-8064-6d2324415543,1f1a0580-a2c8-6cf9-8063-ccdc34329dd4,1f1a0580-880f-69a5-8062-7bd448f52b04,1f1a0580-8025-61a9-8061-770315376849,1f1a0580-3ffb-6d46-8060-6ed130376e2e,1f1a0580-35a5-64fc-805f-6a3d5fe45bb9,1f1a0580-130a-61c6-805e-a818175f0500,1f1a0580-009e-6431-805d-203b8d2fc912,1f1a057f-e2da-6b6c-805c-4962ea69e1f4,1f1a057f-b9ff-69e2-805b-6a7ac914800f,1f1a057f-7f2b-6fb2-805a-6bb937ef6765,1f1a057f-6690-68b1-8059-3d312f2964c3,1f1a057f-52ce-6d88-8058-5324381c089d,1f1a057f-3c68-638e-8057-14e594079e17,1f1a057f-1cb1-6c8d-8056-d5a4aa70c4b2,1f1a057f-0e71-6552-8055-1ebb770a8aad,1f1a057e-fb5f-65ec-8054-59e1b5924868,1f1a057e-e575-62aa-8053-945d1b3642ca,1f1a057e-baed-65c5-8052-6e9a816fe675,1f1a057e-9035-6286-8051-1036364d0516,1f1a057e-7071-6814-8050-f9e22039751c,1f1a057e-4470-643e-804f-298b13fab490,1f1a057d-e80d-6035-804e-b1cccef50a84,1f1a057d-bd44-6733-804d-17cd8154405c,1f1a057d-760f-659b-804c-3142df6fcb36,1f1a057d-5cac-66e5-804b-7d14045905fe,1f1a057d-309b-6d3a-804a-0b225d90df2f,1f1a057d-2778-6ee1-8049-12dff728e0e6,1f1a057d-14e2-680e-8048-b434065d83d0,1f1a057d-0904-61f6-8047-97da009a8189,1f1a057c-f6ef-6316-8046-5975a9e61b9a,1f1a057c-eda7-6c84-8045-90d0a39e8519,1f1a057c-d80a-6b7f-8044-7c5a5f7a6141,1f1a057c-c393-6d67-8043-c1cd4a014810,1f1a057c-a9b2-6749-8042-aa37cb7c35f7,1f1a057c-9716-6e8a-8041-cf06308b22c2,1f1a057c-66c9-655f-8040-6969e8bb3d2e,1f1a057c-2571-6063-803f-b8fb0a6b0328,1f1a057c-1156-6d8b-803e-92159561a5f9,1f1a057c-06f6-69c4-803d-ff502fab6008,1f1a057b-e881-65ac-803c-e68d665ae0f7,1f1a057b-de43-6204-803b-2d5cfb6ec0c5,1f1a057b-ba26-6d62-803a-f710a8b7c013,1f1a057b-a27f-6c45-8039-253ad287d73c,1f1a057b-8b38-6658-8038-6db031cb098e,1f1a057b-8157-611b-8037-3c99aa138f45,1f1a057b-6d7f-6d88-8036-3873dcdfb7f4,1f1a057b-61d0-6e49-8035-e1af53040e6a,1f1a057b-4bf2-63cb-8034-6bbb4f514d0d,1f1a057b-2c3c-66f3-8033-e227d82d45a3,1f1a057b-06dc-6be4-8032-05d0e1a331e7,1f1a057a-e1fe-6177-8031-8a6a09f29a82,1f1a057a-b3ff-6bd2-8030-35516f9a6a75,1f1a057a-9e2e-6b58-802f-9f6fab52baac,1f1a057a-7b64-61c2-802e-d5d6d4f9e023,1f1a057a-6402-62e6-802d-251c46b8c088,1f1a057a-30c0-6a38-802c-9b927ad563c4,1f1a057a-199a-60e6-802b-da698c642466,1f1a0579-fb8a-6a35-802a-909d66b0725c,1f1a0579-c59d-6a75-8029-bbb76e52b65c,1f1a0579-8de3-68d6-8028-c06659552755,1f1a0579-6d91-6f1d-8027-d56c5702e6b7,1f1a0579-4da5-6820-8026-26c98100405c,1f1a0579-3f07-6d5d-8025-7891df64c180,1f1a0579-2e56-644c-8024-344b388ec115,1f1a0579-003f-61fc-8023-b7f7acd6f490,1f1a0578-d0e0-678f-8022-a5dd9522086b,1f1a0578-a857-6923-8021-6c977db5e99e,1f1a0578-850a-6a3e-8020-1b034ffaf7aa,1f1a0578-7b01-69c8-801f-6c958c2aa834,1f1a0578-6ab5-6f46-801e-db34ebf497ac,1f1a0578-5ce9-6385-801d-9c17a1f6bcd1,1f1a0578-4ca9-6606-801c-2ad158bae4bb,1f1a0578-43a4-6bff-801b-ef6048379ef2,1f1a0578-314b-633a-801a-0fff17411b64,1f1a0578-1d7e-62d9-8019-ae9459e87d2f,1f1a0577-ffba-6b19-8018-340e54f0466a,1f1a0577-fc4b-6ba3-8017-4ac5a3b04fd4,1f1a0577-e11c-6f53-8016-f64148dd4f48,1f1a0577-dd6a-61a8-8015-89c482a68e18,1f1a0577-c4dd-6bfa-8014-79bedbf2a721,1f1a0577-bda0-6c65-8013-5e591a297172,1f1a0577-9cf7-6fc5-8012-80c22569de44,1f1a0577-9245-6a24-8011-d5769c3d438e,1f1a0577-73a1-6223-8010-2afc5e655290,1f1a0577-68ab-6308-800f-e57f919d7fdd,1f1a0577-4a69-6a41-800e-d25e729cac58,1f1a0577-4319-657d-800d-39a10f7206c3,1f1a0577-2fe5-6ef7-800c-7612a6e1ed75,1f1a0577-2918-659f-800b-041a10071292,1f1a0577-1793-6395-800a-b8806cdfbfa9,1f1a0577-1016-69a6-8009-f3b1f89edf0f,1f1a0576-f830-687b-8008-cdd8d0da54fc,1f1a0576-ede5-6ca5-8007-1d2fd363bace,1f1a0576-d6a0-6ee7-8006-c60b60f1fa0a,1f1a0576-caed-66fc-8005-6b411cad5b4e,1f1a0576-b17b-6002-8004-2115fe899d13,1f1a0576-a4f9-6fce-8003-721d716dd0f3,1f1a0576-7ffc-6a02-8002-7d74a1e25da7,1f1a0576-6d1e-6b65-8001-87d2b3db7aa5,1f1a0576-5432-6c1f-8000-a137053ae09f,1f1a0576-542d-67da-bfff-2fae96df9ab4}'::text[])))
Buffers: shared hit=156
I/O Timings: read=0.000 write=0.000
Settings: seq_page_cost = '4', effective_cache_size = '472585MB', jit = 'off', random_page_cost = '1.5', work_mem = '230MB'
Query ID: -4790101011256251235
stats:
Time: 5.578 ms
- planning: 4.982 ms
- execution: 0.596 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 159 (~1.20 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
After:
Sort (cost=222.02..222.02 rows=1 width=404) (actual time=0.525..0.557 rows=296 loops=1)
Sort Key: p_duo_workflows_checkpoint_blobs.id
Sort Method: quicksort Memory: 170kB
Buffers: shared hit=159
I/O Timings: read=0.000 write=0.000
-> Index Scan using p_duo_workflows_checkpoint_blobs_20260825_workflow_id_idx on gitlab_partitions_dynamic.p_duo_workflows_checkpoint_blobs_20260825 p_duo_workflows_checkpoint_blobs (cost=0.70..222.01 rows=1 width=404) (actual time=0.037..0.401 rows=296 loops=1)
Index Cond: (p_duo_workflows_checkpoint_blobs.workflow_id = 6606126)
Filter: ((p_duo_workflows_checkpoint_blobs.workflow_created_at = '2026-08-25 07:33:39.179202+00'::timestamp with time zone) AND (p_duo_workflows_checkpoint_blobs.project_id = 14022) AND (p_duo_workflows_checkpoint_blobs.thread_ts = ANY ('{1f1a0581-1af4-6c00-8069-de041748e6f2,1f1a0581-06a5-6669-8068-071efa25ea3f,1f1a0580-f56f-68af-8067-356957e25d62,1f1a0580-db37-6abb-8066-ddd686288b94,1f1a0580-ce03-642f-8065-7441015e4ef6,1f1a0580-acd0-6c43-8064-6d2324415543,1f1a0580-a2c8-6cf9-8063-ccdc34329dd4,1f1a0580-880f-69a5-8062-7bd448f52b04,1f1a0580-8025-61a9-8061-770315376849,1f1a0580-3ffb-6d46-8060-6ed130376e2e,1f1a0580-35a5-64fc-805f-6a3d5fe45bb9,1f1a0580-130a-61c6-805e-a818175f0500,1f1a0580-009e-6431-805d-203b8d2fc912,1f1a057f-e2da-6b6c-805c-4962ea69e1f4,1f1a057f-b9ff-69e2-805b-6a7ac914800f,1f1a057f-7f2b-6fb2-805a-6bb937ef6765,1f1a057f-6690-68b1-8059-3d312f2964c3,1f1a057f-52ce-6d88-8058-5324381c089d,1f1a057f-3c68-638e-8057-14e594079e17,1f1a057f-1cb1-6c8d-8056-d5a4aa70c4b2,1f1a057f-0e71-6552-8055-1ebb770a8aad,1f1a057e-fb5f-65ec-8054-59e1b5924868,1f1a057e-e575-62aa-8053-945d1b3642ca,1f1a057e-baed-65c5-8052-6e9a816fe675,1f1a057e-9035-6286-8051-1036364d0516,1f1a057e-7071-6814-8050-f9e22039751c,1f1a057e-4470-643e-804f-298b13fab490,1f1a057d-e80d-6035-804e-b1cccef50a84,1f1a057d-bd44-6733-804d-17cd8154405c,1f1a057d-760f-659b-804c-3142df6fcb36,1f1a057d-5cac-66e5-804b-7d14045905fe,1f1a057d-309b-6d3a-804a-0b225d90df2f,1f1a057d-2778-6ee1-8049-12dff728e0e6,1f1a057d-14e2-680e-8048-b434065d83d0,1f1a057d-0904-61f6-8047-97da009a8189,1f1a057c-f6ef-6316-8046-5975a9e61b9a,1f1a057c-eda7-6c84-8045-90d0a39e8519,1f1a057c-d80a-6b7f-8044-7c5a5f7a6141,1f1a057c-c393-6d67-8043-c1cd4a014810,1f1a057c-a9b2-6749-8042-aa37cb7c35f7,1f1a057c-9716-6e8a-8041-cf06308b22c2,1f1a057c-66c9-655f-8040-6969e8bb3d2e,1f1a057c-2571-6063-803f-b8fb0a6b0328,1f1a057c-1156-6d8b-803e-92159561a5f9,1f1a057c-06f6-69c4-803d-ff502fab6008,1f1a057b-e881-65ac-803c-e68d665ae0f7,1f1a057b-de43-6204-803b-2d5cfb6ec0c5,1f1a057b-ba26-6d62-803a-f710a8b7c013,1f1a057b-a27f-6c45-8039-253ad287d73c,1f1a057b-8b38-6658-8038-6db031cb098e,1f1a057b-8157-611b-8037-3c99aa138f45,1f1a057b-6d7f-6d88-8036-3873dcdfb7f4,1f1a057b-61d0-6e49-8035-e1af53040e6a,1f1a057b-4bf2-63cb-8034-6bbb4f514d0d,1f1a057b-2c3c-66f3-8033-e227d82d45a3,1f1a057b-06dc-6be4-8032-05d0e1a331e7,1f1a057a-e1fe-6177-8031-8a6a09f29a82,1f1a057a-b3ff-6bd2-8030-35516f9a6a75,1f1a057a-9e2e-6b58-802f-9f6fab52baac,1f1a057a-7b64-61c2-802e-d5d6d4f9e023,1f1a057a-6402-62e6-802d-251c46b8c088,1f1a057a-30c0-6a38-802c-9b927ad563c4,1f1a057a-199a-60e6-802b-da698c642466,1f1a0579-fb8a-6a35-802a-909d66b0725c,1f1a0579-c59d-6a75-8029-bbb76e52b65c,1f1a0579-8de3-68d6-8028-c06659552755,1f1a0579-6d91-6f1d-8027-d56c5702e6b7,1f1a0579-4da5-6820-8026-26c98100405c,1f1a0579-3f07-6d5d-8025-7891df64c180,1f1a0579-2e56-644c-8024-344b388ec115,1f1a0579-003f-61fc-8023-b7f7acd6f490,1f1a0578-d0e0-678f-8022-a5dd9522086b,1f1a0578-a857-6923-8021-6c977db5e99e,1f1a0578-850a-6a3e-8020-1b034ffaf7aa,1f1a0578-7b01-69c8-801f-6c958c2aa834,1f1a0578-6ab5-6f46-801e-db34ebf497ac,1f1a0578-5ce9-6385-801d-9c17a1f6bcd1,1f1a0578-4ca9-6606-801c-2ad158bae4bb,1f1a0578-43a4-6bff-801b-ef6048379ef2,1f1a0578-314b-633a-801a-0fff17411b64,1f1a0578-1d7e-62d9-8019-ae9459e87d2f,1f1a0577-ffba-6b19-8018-340e54f0466a,1f1a0577-fc4b-6ba3-8017-4ac5a3b04fd4,1f1a0577-e11c-6f53-8016-f64148dd4f48,1f1a0577-dd6a-61a8-8015-89c482a68e18,1f1a0577-c4dd-6bfa-8014-79bedbf2a721,1f1a0577-bda0-6c65-8013-5e591a297172,1f1a0577-9cf7-6fc5-8012-80c22569de44,1f1a0577-9245-6a24-8011-d5769c3d438e,1f1a0577-73a1-6223-8010-2afc5e655290,1f1a0577-68ab-6308-800f-e57f919d7fdd,1f1a0577-4a69-6a41-800e-d25e729cac58,1f1a0577-4319-657d-800d-39a10f7206c3,1f1a0577-2fe5-6ef7-800c-7612a6e1ed75,1f1a0577-2918-659f-800b-041a10071292,1f1a0577-1793-6395-800a-b8806cdfbfa9,1f1a0577-1016-69a6-8009-f3b1f89edf0f,1f1a0576-f830-687b-8008-cdd8d0da54fc,1f1a0576-ede5-6ca5-8007-1d2fd363bace,1f1a0576-d6a0-6ee7-8006-c60b60f1fa0a,1f1a0576-caed-66fc-8005-6b411cad5b4e,1f1a0576-b17b-6002-8004-2115fe899d13,1f1a0576-a4f9-6fce-8003-721d716dd0f3,1f1a0576-7ffc-6a02-8002-7d74a1e25da7,1f1a0576-6d1e-6b65-8001-87d2b3db7aa5,1f1a0576-5432-6c1f-8000-a137053ae09f,1f1a0576-542d-67da-bfff-2fae96df9ab4}'::text[])) AND (p_duo_workflows_checkpoint_blobs.channel = ANY ('{status,conversation_history,ui_chat_log,context,agent_context_limits,branch:to:developer_agent#tools}'::text[])))
Rows Removed by Filter: 54
Buffers: shared hit=156
I/O Timings: read=0.000 write=0.000
Settings: seq_page_cost = '4', effective_cache_size = '472585MB', jit = 'off', random_page_cost = '1.5', work_mem = '230MB'
Query ID: 3502423921569859340
stats:
Time: 5.587 ms
- planning: 4.972 ms
- execution: 0.615 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 159 (~1.20 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
Plan pair with forced detoast (count(md5(data)))
Before:
Aggregate (cost=218.54..218.55 rows=1 width=8) (actual time=20.798..20.800 rows=1 loops=1)
Buffers: shared hit=235 read=24
I/O Timings: read=19.219 write=0.000
-> Index Scan using p_duo_workflows_checkpoint_blobs_20260825_workflow_id_idx on gitlab_partitions_dynamic.p_duo_workflows_checkpoint_blobs_20260825 p_duo_workflows_checkpoint_blobs (cost=0.70..218.53 rows=1 width=272) (actual time=0.054..0.600 rows=350 loops=1)
Index Cond: (p_duo_workflows_checkpoint_blobs.workflow_id = 6606126)
Filter: ((p_duo_workflows_checkpoint_blobs.workflow_created_at = '2026-08-25 07:33:39.179202+00'::timestamp with time zone) AND (p_duo_workflows_checkpoint_blobs.project_id = 14022) AND (p_duo_workflows_checkpoint_blobs.thread_ts = ANY ('{1f1a0581-1af4-6c00-8069-de041748e6f2,1f1a0581-06a5-6669-8068-071efa25ea3f,1f1a0580-f56f-68af-8067-356957e25d62,1f1a0580-db37-6abb-8066-ddd686288b94,1f1a0580-ce03-642f-8065-7441015e4ef6,1f1a0580-acd0-6c43-8064-6d2324415543,1f1a0580-a2c8-6cf9-8063-ccdc34329dd4,1f1a0580-880f-69a5-8062-7bd448f52b04,1f1a0580-8025-61a9-8061-770315376849,1f1a0580-3ffb-6d46-8060-6ed130376e2e,1f1a0580-35a5-64fc-805f-6a3d5fe45bb9,1f1a0580-130a-61c6-805e-a818175f0500,1f1a0580-009e-6431-805d-203b8d2fc912,1f1a057f-e2da-6b6c-805c-4962ea69e1f4,1f1a057f-b9ff-69e2-805b-6a7ac914800f,1f1a057f-7f2b-6fb2-805a-6bb937ef6765,1f1a057f-6690-68b1-8059-3d312f2964c3,1f1a057f-52ce-6d88-8058-5324381c089d,1f1a057f-3c68-638e-8057-14e594079e17,1f1a057f-1cb1-6c8d-8056-d5a4aa70c4b2,1f1a057f-0e71-6552-8055-1ebb770a8aad,1f1a057e-fb5f-65ec-8054-59e1b5924868,1f1a057e-e575-62aa-8053-945d1b3642ca,1f1a057e-baed-65c5-8052-6e9a816fe675,1f1a057e-9035-6286-8051-1036364d0516,1f1a057e-7071-6814-8050-f9e22039751c,1f1a057e-4470-643e-804f-298b13fab490,1f1a057d-e80d-6035-804e-b1cccef50a84,1f1a057d-bd44-6733-804d-17cd8154405c,1f1a057d-760f-659b-804c-3142df6fcb36,1f1a057d-5cac-66e5-804b-7d14045905fe,1f1a057d-309b-6d3a-804a-0b225d90df2f,1f1a057d-2778-6ee1-8049-12dff728e0e6,1f1a057d-14e2-680e-8048-b434065d83d0,1f1a057d-0904-61f6-8047-97da009a8189,1f1a057c-f6ef-6316-8046-5975a9e61b9a,1f1a057c-eda7-6c84-8045-90d0a39e8519,1f1a057c-d80a-6b7f-8044-7c5a5f7a6141,1f1a057c-c393-6d67-8043-c1cd4a014810,1f1a057c-a9b2-6749-8042-aa37cb7c35f7,1f1a057c-9716-6e8a-8041-cf06308b22c2,1f1a057c-66c9-655f-8040-6969e8bb3d2e,1f1a057c-2571-6063-803f-b8fb0a6b0328,1f1a057c-1156-6d8b-803e-92159561a5f9,1f1a057c-06f6-69c4-803d-ff502fab6008,1f1a057b-e881-65ac-803c-e68d665ae0f7,1f1a057b-de43-6204-803b-2d5cfb6ec0c5,1f1a057b-ba26-6d62-803a-f710a8b7c013,1f1a057b-a27f-6c45-8039-253ad287d73c,1f1a057b-8b38-6658-8038-6db031cb098e,1f1a057b-8157-611b-8037-3c99aa138f45,1f1a057b-6d7f-6d88-8036-3873dcdfb7f4,1f1a057b-61d0-6e49-8035-e1af53040e6a,1f1a057b-4bf2-63cb-8034-6bbb4f514d0d,1f1a057b-2c3c-66f3-8033-e227d82d45a3,1f1a057b-06dc-6be4-8032-05d0e1a331e7,1f1a057a-e1fe-6177-8031-8a6a09f29a82,1f1a057a-b3ff-6bd2-8030-35516f9a6a75,1f1a057a-9e2e-6b58-802f-9f6fab52baac,1f1a057a-7b64-61c2-802e-d5d6d4f9e023,1f1a057a-6402-62e6-802d-251c46b8c088,1f1a057a-30c0-6a38-802c-9b927ad563c4,1f1a057a-199a-60e6-802b-da698c642466,1f1a0579-fb8a-6a35-802a-909d66b0725c,1f1a0579-c59d-6a75-8029-bbb76e52b65c,1f1a0579-8de3-68d6-8028-c06659552755,1f1a0579-6d91-6f1d-8027-d56c5702e6b7,1f1a0579-4da5-6820-8026-26c98100405c,1f1a0579-3f07-6d5d-8025-7891df64c180,1f1a0579-2e56-644c-8024-344b388ec115,1f1a0579-003f-61fc-8023-b7f7acd6f490,1f1a0578-d0e0-678f-8022-a5dd9522086b,1f1a0578-a857-6923-8021-6c977db5e99e,1f1a0578-850a-6a3e-8020-1b034ffaf7aa,1f1a0578-7b01-69c8-801f-6c958c2aa834,1f1a0578-6ab5-6f46-801e-db34ebf497ac,1f1a0578-5ce9-6385-801d-9c17a1f6bcd1,1f1a0578-4ca9-6606-801c-2ad158bae4bb,1f1a0578-43a4-6bff-801b-ef6048379ef2,1f1a0578-314b-633a-801a-0fff17411b64,1f1a0578-1d7e-62d9-8019-ae9459e87d2f,1f1a0577-ffba-6b19-8018-340e54f0466a,1f1a0577-fc4b-6ba3-8017-4ac5a3b04fd4,1f1a0577-e11c-6f53-8016-f64148dd4f48,1f1a0577-dd6a-61a8-8015-89c482a68e18,1f1a0577-c4dd-6bfa-8014-79bedbf2a721,1f1a0577-bda0-6c65-8013-5e591a297172,1f1a0577-9cf7-6fc5-8012-80c22569de44,1f1a0577-9245-6a24-8011-d5769c3d438e,1f1a0577-73a1-6223-8010-2afc5e655290,1f1a0577-68ab-6308-800f-e57f919d7fdd,1f1a0577-4a69-6a41-800e-d25e729cac58,1f1a0577-4319-657d-800d-39a10f7206c3,1f1a0577-2fe5-6ef7-800c-7612a6e1ed75,1f1a0577-2918-659f-800b-041a10071292,1f1a0577-1793-6395-800a-b8806cdfbfa9,1f1a0577-1016-69a6-8009-f3b1f89edf0f,1f1a0576-f830-687b-8008-cdd8d0da54fc,1f1a0576-ede5-6ca5-8007-1d2fd363bace,1f1a0576-d6a0-6ee7-8006-c60b60f1fa0a,1f1a0576-caed-66fc-8005-6b411cad5b4e,1f1a0576-b17b-6002-8004-2115fe899d13,1f1a0576-a4f9-6fce-8003-721d716dd0f3,1f1a0576-7ffc-6a02-8002-7d74a1e25da7,1f1a0576-6d1e-6b65-8001-87d2b3db7aa5,1f1a0576-5432-6c1f-8000-a137053ae09f,1f1a0576-542d-67da-bfff-2fae96df9ab4}'::text[])))
Buffers: shared hit=156
I/O Timings: read=0.000 write=0.000
Settings: seq_page_cost = '4', effective_cache_size = '472585MB', jit = 'off', random_page_cost = '1.5', work_mem = '230MB'
Query ID: -7577457295041246152
stats:
Time: 27.268 ms
- planning: 6.381 ms
- execution: 20.887 ms
- I/O read: 19.219 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 235 (~1.80 MiB) from the buffer pool
- reads: 24 (~192.00 KiB) from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
After:
Aggregate (cost=222.01..222.02 rows=1 width=8) (actual time=0.919..0.920 rows=1 loops=1)
Buffers: shared hit=259
I/O Timings: read=0.000 write=0.000
-> Index Scan using p_duo_workflows_checkpoint_blobs_20260825_workflow_id_idx on gitlab_partitions_dynamic.p_duo_workflows_checkpoint_blobs_20260825 p_duo_workflows_checkpoint_blobs (cost=0.70..222.01 rows=1 width=272) (actual time=0.036..0.380 rows=296 loops=1)
Index Cond: (p_duo_workflows_checkpoint_blobs.workflow_id = 6606126)
Filter: ((p_duo_workflows_checkpoint_blobs.workflow_created_at = '2026-08-25 07:33:39.179202+00'::timestamp with time zone) AND (p_duo_workflows_checkpoint_blobs.project_id = 14022) AND (p_duo_workflows_checkpoint_blobs.thread_ts = ANY ('{1f1a0581-1af4-6c00-8069-de041748e6f2,1f1a0581-06a5-6669-8068-071efa25ea3f,1f1a0580-f56f-68af-8067-356957e25d62,1f1a0580-db37-6abb-8066-ddd686288b94,1f1a0580-ce03-642f-8065-7441015e4ef6,1f1a0580-acd0-6c43-8064-6d2324415543,1f1a0580-a2c8-6cf9-8063-ccdc34329dd4,1f1a0580-880f-69a5-8062-7bd448f52b04,1f1a0580-8025-61a9-8061-770315376849,1f1a0580-3ffb-6d46-8060-6ed130376e2e,1f1a0580-35a5-64fc-805f-6a3d5fe45bb9,1f1a0580-130a-61c6-805e-a818175f0500,1f1a0580-009e-6431-805d-203b8d2fc912,1f1a057f-e2da-6b6c-805c-4962ea69e1f4,1f1a057f-b9ff-69e2-805b-6a7ac914800f,1f1a057f-7f2b-6fb2-805a-6bb937ef6765,1f1a057f-6690-68b1-8059-3d312f2964c3,1f1a057f-52ce-6d88-8058-5324381c089d,1f1a057f-3c68-638e-8057-14e594079e17,1f1a057f-1cb1-6c8d-8056-d5a4aa70c4b2,1f1a057f-0e71-6552-8055-1ebb770a8aad,1f1a057e-fb5f-65ec-8054-59e1b5924868,1f1a057e-e575-62aa-8053-945d1b3642ca,1f1a057e-baed-65c5-8052-6e9a816fe675,1f1a057e-9035-6286-8051-1036364d0516,1f1a057e-7071-6814-8050-f9e22039751c,1f1a057e-4470-643e-804f-298b13fab490,1f1a057d-e80d-6035-804e-b1cccef50a84,1f1a057d-bd44-6733-804d-17cd8154405c,1f1a057d-760f-659b-804c-3142df6fcb36,1f1a057d-5cac-66e5-804b-7d14045905fe,1f1a057d-309b-6d3a-804a-0b225d90df2f,1f1a057d-2778-6ee1-8049-12dff728e0e6,1f1a057d-14e2-680e-8048-b434065d83d0,1f1a057d-0904-61f6-8047-97da009a8189,1f1a057c-f6ef-6316-8046-5975a9e61b9a,1f1a057c-eda7-6c84-8045-90d0a39e8519,1f1a057c-d80a-6b7f-8044-7c5a5f7a6141,1f1a057c-c393-6d67-8043-c1cd4a014810,1f1a057c-a9b2-6749-8042-aa37cb7c35f7,1f1a057c-9716-6e8a-8041-cf06308b22c2,1f1a057c-66c9-655f-8040-6969e8bb3d2e,1f1a057c-2571-6063-803f-b8fb0a6b0328,1f1a057c-1156-6d8b-803e-92159561a5f9,1f1a057c-06f6-69c4-803d-ff502fab6008,1f1a057b-e881-65ac-803c-e68d665ae0f7,1f1a057b-de43-6204-803b-2d5cfb6ec0c5,1f1a057b-ba26-6d62-803a-f710a8b7c013,1f1a057b-a27f-6c45-8039-253ad287d73c,1f1a057b-8b38-6658-8038-6db031cb098e,1f1a057b-8157-611b-8037-3c99aa138f45,1f1a057b-6d7f-6d88-8036-3873dcdfb7f4,1f1a057b-61d0-6e49-8035-e1af53040e6a,1f1a057b-4bf2-63cb-8034-6bbb4f514d0d,1f1a057b-2c3c-66f3-8033-e227d82d45a3,1f1a057b-06dc-6be4-8032-05d0e1a331e7,1f1a057a-e1fe-6177-8031-8a6a09f29a82,1f1a057a-b3ff-6bd2-8030-35516f9a6a75,1f1a057a-9e2e-6b58-802f-9f6fab52baac,1f1a057a-7b64-61c2-802e-d5d6d4f9e023,1f1a057a-6402-62e6-802d-251c46b8c088,1f1a057a-30c0-6a38-802c-9b927ad563c4,1f1a057a-199a-60e6-802b-da698c642466,1f1a0579-fb8a-6a35-802a-909d66b0725c,1f1a0579-c59d-6a75-8029-bbb76e52b65c,1f1a0579-8de3-68d6-8028-c06659552755,1f1a0579-6d91-6f1d-8027-d56c5702e6b7,1f1a0579-4da5-6820-8026-26c98100405c,1f1a0579-3f07-6d5d-8025-7891df64c180,1f1a0579-2e56-644c-8024-344b388ec115,1f1a0579-003f-61fc-8023-b7f7acd6f490,1f1a0578-d0e0-678f-8022-a5dd9522086b,1f1a0578-a857-6923-8021-6c977db5e99e,1f1a0578-850a-6a3e-8020-1b034ffaf7aa,1f1a0578-7b01-69c8-801f-6c958c2aa834,1f1a0578-6ab5-6f46-801e-db34ebf497ac,1f1a0578-5ce9-6385-801d-9c17a1f6bcd1,1f1a0578-4ca9-6606-801c-2ad158bae4bb,1f1a0578-43a4-6bff-801b-ef6048379ef2,1f1a0578-314b-633a-801a-0fff17411b64,1f1a0578-1d7e-62d9-8019-ae9459e87d2f,1f1a0577-ffba-6b19-8018-340e54f0466a,1f1a0577-fc4b-6ba3-8017-4ac5a3b04fd4,1f1a0577-e11c-6f53-8016-f64148dd4f48,1f1a0577-dd6a-61a8-8015-89c482a68e18,1f1a0577-c4dd-6bfa-8014-79bedbf2a721,1f1a0577-bda0-6c65-8013-5e591a297172,1f1a0577-9cf7-6fc5-8012-80c22569de44,1f1a0577-9245-6a24-8011-d5769c3d438e,1f1a0577-73a1-6223-8010-2afc5e655290,1f1a0577-68ab-6308-800f-e57f919d7fdd,1f1a0577-4a69-6a41-800e-d25e729cac58,1f1a0577-4319-657d-800d-39a10f7206c3,1f1a0577-2fe5-6ef7-800c-7612a6e1ed75,1f1a0577-2918-659f-800b-041a10071292,1f1a0577-1793-6395-800a-b8806cdfbfa9,1f1a0577-1016-69a6-8009-f3b1f89edf0f,1f1a0576-f830-687b-8008-cdd8d0da54fc,1f1a0576-ede5-6ca5-8007-1d2fd363bace,1f1a0576-d6a0-6ee7-8006-c60b60f1fa0a,1f1a0576-caed-66fc-8005-6b411cad5b4e,1f1a0576-b17b-6002-8004-2115fe899d13,1f1a0576-a4f9-6fce-8003-721d716dd0f3,1f1a0576-7ffc-6a02-8002-7d74a1e25da7,1f1a0576-6d1e-6b65-8001-87d2b3db7aa5,1f1a0576-5432-6c1f-8000-a137053ae09f,1f1a0576-542d-67da-bfff-2fae96df9ab4}'::text[])) AND (p_duo_workflows_checkpoint_blobs.channel = ANY ('{status,conversation_history,ui_chat_log,context,agent_context_limits,branch:to:developer_agent#tools}'::text[])))
Rows Removed by Filter: 54
Buffers: shared hit=156
I/O Timings: read=0.000 write=0.000
Settings: jit = 'off', random_page_cost = '1.5', work_mem = '230MB', seq_page_cost = '4', effective_cache_size = '472585MB'
Query ID: -353844771557801625
stats:
Time: 6.406 ms
- planning: 5.423 ms
- execution: 0.983 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 259 (~2.00 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
On this workflow, the before and after queries touch the same pages: 159 shared buffers each, about 0.6 ms warm. That's because the planner drives both through the partition's single-column workflow_id index and applies every other predicate as a filter — the same shape we saw locally. The channel predicate removes 54 rows at scan time, before they reach Rails. A forced-detoast pair (count(md5(data))) showed no meaningful TOAST difference: 259 vs 259 buffers. Production routing blobs are around 10 bytes, not the fat re-seeded snapshots the issue assumed. So the DB-side gain here is modest. The real win is 54 fewer rows shipped to Rails and zlib-inflated per read, and it scales with a workflow's dead-channel row share. Pages where every header declares an empty membership now skip the blob query entirely. The getLatestCheckpoint p95 re-measure after deploy will show how much of the legacy-vs-blobs gap this actually closes.
- Query plans (production, Database Lab)
- Re-measure
getLatestCheckpointp95 after deploy.
References
- Resolves #624938 (closed)
- Membership filter (Ruby-side): !251344 (merged)
- Related issues: #613975 (closed) (membership filter), #621934 (closed) (blob index for latest_channel_message)
- Epic: &23217 (closed)