-
Notifications
You must be signed in to change notification settings - Fork 155
Description
Some statistics would be helpful.
I've recently set up an attic instance and wanted to evaluate how the storage use compares to a flat-file binary cache, and came up with the following queries:
atticd=# select pg_size_pretty(total_nar_size) total_nar_size, pg_size_pretty(total_compressed_nar_size) total_compressed_nar_size, pg_size_pretty(total_chunk_size) uncompressed_chunk_size, pg_size_pretty(total_storage_used) total_storage_used, total_compressed_nar_size / total_storage_used ratio from (select (select sum(nar_size) from nar) total_nar_size, (select sum(chunk_size) from chunk) total_chunk_size, (select sum(file_size) from chunk) total_storage_used, (select sum(compressed_nar_size) total_compressed_nar_size from (select sum(file_size) compressed_nar_size from nar, chunkref, chunk where nar_id = nar.id and chunk_id = chunk.id group by nar.id)));
total_nar_size | total_compressed_nar_size | uncompressed_chunk_size | total_storage_used | ratio
----------------+---------------------------+-------------------------+--------------------+--------------------
9157 MB | 3145 MB | 4843 MB | 1708 MB | 1.8419919245644854
(1 row)
ratio is an approximation of how much space is saved (for nars only, not narinfos!) compared to a flat-file binary cache.
This is a single-tenant instance, so I haven't spent much thought on getting these stats per cache, but they're probably useful as-is even from a multi-tenant operator perspective (though they don't shed any light on how much deduplication happens across tenants). It would probably also not be complicated to get these numbers per cache, which could be useful from an individual tenant perspective as well.
Maybe something like this could be surfaced via the API? Somewhat related to #7.