Skip to content

Instantly share code, notes, and snippets.

@ayush--s
Created October 15, 2021 10:27
Show Gist options
  • Select an option

  • Save ayush--s/2838a27242d345890ee5bde70d0e4555 to your computer and use it in GitHub Desktop.

Select an option

Save ayush--s/2838a27242d345890ee5bde70d0e4555 to your computer and use it in GitHub Desktop.

Revisions

  1. ayush--s created this gist Oct 15, 2021.
    31 changes: 31 additions & 0 deletions chunk-details.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    WITH size AS (
    SELECT
    concat(chunk_schema, '.', chunk_name) AS name,
    round(table_bytes / (1024 * 1024.0), 2) AS table_megs,
    round(index_bytes / (1024 * 1024.0), 2) AS index_megs,
    round(total_bytes / (1024 * 1024.0), 2) AS total_megs
    FROM
    chunks_detailed_size ('%%table%%')
    ORDER BY
    chunk_name,
    node_name
    ),
    timerange AS (
    SELECT
    *
    FROM
    chunks_tstz
    WHERE
    hypertable::text = '%%table%%'
    )
    SELECT
    chunk,
    table_megs,
    index_megs,
    total_megs,
    time_range
    FROM
    size s
    INNER JOIN timerange t ON s.name = t.chunk::text
    ORDER BY
    time_range DESC