-
Notifications
You must be signed in to change notification settings - Fork 1
Description
When monitoring pg_stat_activity, we track which processes are blocking or blocked by other processes. Each backend has an array of PIDs for these fields which have a variable length. In order to flatten those so that pco can compress them, we can split it up into two arrays: the first array tracks the length of each nested array, and the second array is a flat concatenation of all values.
So this data:
[[1,2,3],[4,5],[6]]Is transformed into this before compression:
[3,2,1]
[1,2,3,4,5,6]Allowing wrapped structs to have array fields:
#[pco_store::store(timestamp = collected_at, group_by = [server_id])]
pub struct BackendSnapshot {
pub server_id: i64,
pub collected_at: SystemTime,
pub pid: i64,
pub blocking_pids: Vec<i64>,
pub blocked_by_pids: Vec<i64>,
}Note: both array lengths and flat values would be concatenated to a single byte array after compression. Does pco support partial decompression of bytes? If not, every pco-compressed blob is prefixed with an identifier so we can at least split the bytes using that. The design should keep #18 in mind; is there a common pattern or crate we can use?