Skip to main content
Question

Does VAdvisor give the compressed DB size?

  • November 11, 2021
  • 2 replies
  • 7 views

DieterC
Forum|alt.badge.img+2

Hi forum,
to plan a database migration I am after the physical size of a full backup. I am after something like the result from
select sum(used_bytes) from projection_storage;
Is this info available from a VAdvisor report please? Where can it be found?
Thank you
Dieter

2 replies

mosheg
Forum|alt.badge.img+2
  • Participating Frequently
  • November 13, 2021

Hello Dieter,

The following example return the raw data size (in bytes) of a database as it is counted in an audit of the database size:
select audit('');

audit

16252460269
(1 row)

select 16252460269/1024^3 AS GB;

GB

15.1362831415609
(1 row)

Here is an example for both, compressed and uncompressed data for all DB objects you can edit to get only the totals:
This info is not shown in Vadvisor.

-- First run audit, for example:
SELECT AUDIT('','table',5,95);       -- error tolerance=5, confidence level=95%

WITH MAXUA AS
    (SELECT audited_schema_name || '.' || audited_object_name AS S_TABLE,
            object_type,
            MAX(audit_end_timestamp) AS MAXAUDIT
     FROM v_catalog.user_audits
     WHERE object_type = 'TABLE'
     GROUP BY 1,
              2),
PS AS
    (SELECT anchor_table_schema || '.' || anchor_table_name AS S_TABLE,
            SUM(used_bytes) AS compressed_bytes,
            sum(row_count)  AS projections_row_count,
            count(distinct projection_id) as projections_number
     FROM v_monitor.projection_storage
     GROUP BY 1)
SELECT UA.audited_schema_name || '.' || UA.audited_object_name AS S_TABLE,
       PS.projections_row_count,
       PS.projections_number,
       (UA.size_bytes / NULLIFZERO(PS.compressed_bytes))::NUMERIC(10,1) AS compression_ratio,
       UA.size_bytes::NUMERIC(20,1) AS Uncompressed_Bytes,
       PS.compressed_bytes::NUMERIC(20,1) AS Compressed_Bytes,
       (UA.size_bytes / (1024^3))::NUMERIC(20,1) AS Uncompressed_GB,
       (PS.compressed_bytes / (1024^3))::NUMERIC(20,1) AS Compressed_GB
FROM v_catalog.user_audits UA,
     MAXUA,
     PS
WHERE UA.object_type = 'TABLE'
    AND UA.audited_schema_name || '.' || UA.audited_object_name = MAXUA.S_TABLE
    AND PS.S_TABLE = MAXUA.S_TABLE
    AND UA.audit_end_timestamp = MAXUA.MAXAUDIT
ORDER BY 8 desc;
              S_TABLE               | projections_row_count | projections_number | compression_ratio | Uncompressed_Bytes | Compressed_Bytes | Uncompressed_GB | Compressed_GB
------------------------------------+-----------------------+--------------------+-------------------+--------------------+------------------+-----------------+---------------
store.store_orders_fact            |             100000000 |                  1 |               3.0 |       9566903776.0 |     3215358831.0 |             8.9 |           3.0
store.store_sales_fact             |             100000000 |                  1 |               2.5 |       6136634322.0 |     2494954112.0 |             5.7 |           2.3
public.shipping_dimension          |              10000000 |                  1 |               3.9 |        272356000.0 |       69034680.0 |             0.3 |           0.1
public.customer_dimension          |               1000000 |                  1 |               2.6 |        111218836.0 |       43305481.0 |             0.1 |           0.0
public.product_dimension           |                100000 |                  1 |               2.4 |          9447908.0 |        3955957.0 |             0.0 |           0.0
public.promotion_dimension         |                   100 |                  1 |               2.1 |            11026.0 |           5275.0 |             0.0 |           0.0
public.date_dimension              |                  1096 |                  1 |               4.1 |           109529.0 |          26621.0 |             0.0 |           0.0
public.warehouse_dimension         |                  1000 |                  1 |               2.2 |            42453.0 |          19658.0 |             0.0 |           0.0
public.inventory_fact              |               1000000 |                  1 |               1.9 |         14355500.0 |        7398422.0 |             0.0 |           0.0
store.store_dimension              |                  1000 |                  1 |               2.2 |            89368.0 |          41100.0 |             0.0 |           0.0
public.employee_dimension          |                 10000 |                  1 |               2.6 |           901495.0 |         341994.0 |             0.0 |           0.0
public.vendor_dimension            |                  1000 |                  1 |               2.3 |            61639.0 |          26864.0 |             0.0 |           0.0
online_sales.online_page_dimension |                 10000 |                  1 |               6.1 |           599801.0 |          97953.0 |             0.0 |           0.0
online_sales.call_center_dimension |                100000 |                  1 |               3.7 |          9134454.0 |        2446864.0 |             0.0 |           0.0
online_sales.online_sales_fact     |               1000000 |                  1 |               1.7 |         66104379.0 |       38415207.0 |             0.1 |           0.0
public.generated_data              |                     0 |                  1 |                   |                0.0 |              0.0 |             0.0 |           0.0
(16 rows)

Hope it helps.


DieterC
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • November 15, 2021

Thank you Moshe,

I was not sure if the VA report would have something like this on system level. I am looking for an approach without system access.
Following Pravesh advice I used the grasp DB in this way

select * from grasp.scrutinSummary
--where account_name = 'xxx' -- finde the scrutinizes for the customer
where database_name = 'gbaprd'
order by load_timestamp desc limit 30;

ALTER SESSION SET UDPARAMETER SCRUTIN_ID=20210331151131;
SET SEARCH_PATH=Grasp,public;

select sum(used_bytes) from projection_storage;
10.418.497.360.664

This works. Incredible!

Best
Dieter