SELECT
-schemaname,relname as "Table",
+schemaname as schema_name,relname as "Table",
indexrelname AS indexname,
pg_relation_size(indexrelid),
pg_size_pretty(pg_relation_size(indexrelid)) AS index_size
@@ -523,14 +567,22 @@ SELECT p.pid, now() - a.xact_start AS duration, coalesce(wait_event_type ||'.'||
\qecho
\qecho Autovacuum progress per day:
\qecho
+\qecho Note:
+\qecho This section presents the number of tables that have been vacuumed by the autovacuum , grouped by the date (in the format YYYY-MM-DD) of the last_autovacuum column.
+\qecho If the value in the date column is NULL, it indicates that the corresponding value in the table count column represents the number of tables that the autovacuum did not vacuum.
+\qecho
\qecho
-select to_char(last_autovacuum, 'YYYY-MM-DD') as date , count(*) from pg_stat_all_tables group by to_char(last_autovacuum, 'YYYY-MM-DD') order by 1;
+select to_char(last_autovacuum, 'YYYY-MM-DD') as date , count(*) as table_count from pg_stat_all_tables group by to_char(last_autovacuum, 'YYYY-MM-DD') order by 1;
\qecho
\qecho
\qecho Autoanalyze progress per day:
\qecho
+\qecho Note:
+\qecho This section presents the number of tables that have been analyzed by the autoanalyze , grouped by the date (in the format YYYY-MM-DD) of the last_autoanalyze column.
+\qecho If the value in the date column is NULL, it indicates that the corresponding value in the table count column represents the number of tables that the autoanalyze did not analyze.
+\qecho
\qecho
-select to_char(last_autoanalyze, 'YYYY-MM-DD') as date , count(*) from pg_stat_all_tables group by to_char(last_autoanalyze, 'YYYY-MM-DD') order by 1;
+select to_char(last_autoanalyze, 'YYYY-MM-DD') as date , count(*) as table_count from pg_stat_all_tables group by to_char(last_autoanalyze, 'YYYY-MM-DD') order by 1;
\qecho
\qecho
--Which tables are currently eligible for autovacuum based on curret parameters
@@ -575,7 +627,7 @@ SELECT name, setting FROM pg_settings WHERE name='track_counts';
\qecho Top 50 tables based on number of dead tuples:
\qecho
\qecho
-select relname,n_live_tup, n_tup_upd, n_tup_del, n_dead_tup, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze from pg_stat_all_tables order by n_dead_tup desc limit 50;
+select schemaname as schema_name,relname AS table_name,n_live_tup, n_tup_upd, n_tup_del, n_dead_tup, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze from pg_stat_all_tables order by n_dead_tup desc limit 50;
\qecho
\qecho
\qecho Tables have more than 20% dead rows :
@@ -764,6 +816,8 @@ FROM
\qecho
\qecho pg_stat_statements extension
\qecho
+select count(*) > 0 is_pg_stat_statements_enabled FROM pg_catalog.pg_extension where extname = 'pg_stat_statements' \gset
+\if :is_pg_stat_statements_enabled
\qecho pg_stat_statements installed version:
\qecho
\qecho
@@ -898,6 +952,11 @@ shared_blks_read
from pg_stat_statements
order by shared_blks_read desc limit 20;
\qecho
+\else
+ \if yes
+ \qecho 'pg_stat_statements extension is not installed'
+ \endif
+\endif
\qecho [Top]
@@ -1368,11 +1427,11 @@ order by physical_reads_percent desc limit 50 ;
\qecho
SELECT
current_database(), schemaname, tablename, /*reltuples::bigint, relpages::bigint, otta,*/
- ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS "table_bloat_%",
+ ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS "table_bloat_ratio",
CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END AS wastedbytes,
pg_size_pretty(CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END) AS table_wasted_size,
iname AS Index_nam, /*ituples::bigint, ipages::bigint, iotta,*/
- ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS "Index_bloat_%",
+ ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS "Index_bloat_ratio",
CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END AS wastedibytes,
pg_size_pretty(CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) ::BIGINT END) AS Index_wasted_size
FROM (
@@ -1416,16 +1475,16 @@ ORDER BY wastedbytes DESC;
\qecho
\qecho
-\qecho
Tables and indexes Bloat [Fragmentation] order by table wasted % :
+\qecho Tables and indexes Bloat [Fragmentation] order by table wasted ratio :
\qecho
\qecho
SELECT
current_database(), schemaname, tablename, /*reltuples::bigint, relpages::bigint, otta,*/
- ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS "table_bloat_%",
+ ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS "table_bloat_ratio",
CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END AS wastedbytes,
pg_size_pretty(CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END) AS table_wasted_size,
iname AS Index_nam, /*ituples::bigint, ipages::bigint, iotta,*/
- ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS "Index_bloat_%",
+ ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS "Index_bloat_ratio",
CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END AS wastedibytes,
pg_size_pretty(CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) ::BIGINT END) AS Index_wasted_size
FROM (
@@ -1469,16 +1528,16 @@ ORDER BY 4 desc;
\qecho
\qecho
-\qecho Tables and indexes Bloat [Fragmentation] order by index wasted % :
+\qecho Tables and indexes Bloat [Fragmentation] order by index wasted ratio :
\qecho
\qecho
SELECT
current_database(), schemaname, tablename, /*reltuples::bigint, relpages::bigint, otta,*/
- ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS "table_bloat_%",
+ ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS "table_bloat_ratio",
CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END AS wastedbytes,
pg_size_pretty(CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END) AS table_wasted_size,
iname AS Index_nam, /*ituples::bigint, ipages::bigint, iotta,*/
- ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS "Index_bloat_%",
+ ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS "Index_bloat_ratio",
CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END AS wastedibytes,
pg_size_pretty(CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) ::BIGINT END) AS Index_wasted_size
FROM (
@@ -2500,7 +2559,14 @@ order by table_id , trigger_status_code;
\qecho
\qecho The view pg_config describes the compile-time configuration parameters of the currently installed version of PostgreSQL.
\qecho
-select * from pg_config();
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+\qecho 'pg_config() is currently not supported for Aurora'
+\else
+ \if yes
+ select * from pg_config();
+ \endif
+\endif
\qecho
\qecho [Top]
@@ -2520,6 +2586,31 @@ SELECT * FROM pg_settings where name in ('rds.extensions') order by category;
\qecho
[Top]
+-- +----------------------------------------------------------------------------+
+-- | - Invalid_databases - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Invalid databases
+\qecho
+\qecho If the DROP DATABASE command is interrupted, the database will become invalid,starting from versions 11.21 and later, 12.16 and later, 13.12 and later, 14.9 and later, 15.4 and later, all versions of 16 as well as PostgreSQL 16 and all subsequent major versions.
+\qecho you will not be able to connect to it again. In this case, you will see the below error message:
+\qecho failed: FATAL: cannot connect to invalid database
+\qecho HINT: Use DROP DATABASE to drop invalid databases.
+\qecho
+\qecho
+\qecho Invalid databases count:
+select count(*) FROM pg_database WHERE datconnlimit = '-2' ;
+
+\qecho
+\qecho Invalid databases list:
+SELECT * FROM pg_database WHERE datconnlimit = '-2' ;
+\qecho
+
+\qecho [Top]
+
+
-- +----------------------------------------------------------------------------+
-- | - ************* - |
-- +----------------------------------------------------------------------------+
@@ -2534,5 +2625,400 @@ SELECT * FROM pg_settings where name in ('rds.extensions') order by category;
\qecho
[Top]
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_version - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora version
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT * FROM aurora_version();
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+
+\qecho [Top]
+
+
+
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_PostgreSQL_built-in_functions - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora PostgreSQL built-in functions
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT * FROM aurora_list_builtins();
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_db_instance_identifier - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora db instance identifier
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT server_id,
+ CASE
+ WHEN 'MASTER_SESSION_ID' = session_id THEN 'writer'
+ ELSE 'reader'
+ END AS instance_role
+FROM aurora_replica_status() rt,
+ aurora_db_instance_identifier() di
+ WHERE rt.server_id = di;
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_cluster_instances - |
+-- +----------------------------------------------------------------------------+
+
+\qecho
+\qecho Aurora cluster instances
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+ SELECT server_id,
+ CASE
+ WHEN 'MASTER_SESSION_ID' = session_id THEN 'writer'
+ ELSE 'reader'
+ END AS instance_role
+FROM aurora_replica_status() ;
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_reader_instances-Replica_Lag - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora reader instances - Replica Lag
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT server_id,
+ CASE
+ WHEN 'MASTER_SESSION_ID' = session_id THEN 'writer'
+ ELSE 'reader'
+ END AS instance_role,
+ replica_lag_in_msec AS replica_lag_ms,
+ round(extract (epoch FROM (SELECT age(clock_timestamp(), last_update_timestamp))) * 1000) AS last_update_age_ms
+FROM aurora_replica_status()
+ORDER BY replica_lag_in_msec NULLS FIRST;
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_cluster_cache_management_(CCM) - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora cluster cache management (CCM)
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT * FROM aurora_ccm_status();
+SELECT buffers_sent_last_minute * 8/60 AS warm_rate_kbps,
+100 * (1.0-buffers_sent_last_scan/buffers_found_last_scan) AS warm_percent
+FROM aurora_ccm_status ();
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_global_db_status - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora global db status
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT CASE
+ WHEN '-1' = durability_lag_in_msec THEN 'Primary'
+ ELSE 'Secondary'
+ END AS global_role,
+ *
+ FROM aurora_global_db_status();
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_wait_event_stat - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Aurora wait event stat
+\qecho
+\qecho Note:
+\qecho aurora_stat_system_waits()function returns the cumulative number of waits and cumulative wait time for each wait event generated by the DB instance that you are currently connected to.
+\qecho Statistics returned by this function are reset when a DB instance restarts.
+\qecho waits :The number of times the wait event occurred.
+\qecho wait_time : The total amount of time in microseconds spent waiting for this event.
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+SELECT type_name as wait_event_type,
+ event_name as wait_event_name,
+ waits,
+ wait_time
+ FROM aurora_stat_system_waits()
+NATURAL JOIN aurora_stat_wait_event()
+NATURAL JOIN aurora_stat_wait_type() order by wait_time desc;
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+
+-- +----------------------------------------------------------------------------+
+-- | - query_plan_management - |
+-- +----------------------------------------------------------------------------+
+
+\qecho
+\qecho Query Plan Management (QPM)
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+select count(*) > 0 is_apg_plan_mgmt_enabled FROM pg_catalog.pg_extension where extname = 'apg_plan_mgmt' \gset
+select count(*) = 0 is_apg_plan_mgmt_not_enabled FROM pg_catalog.pg_extension where extname = 'apg_plan_mgmt' \gset
+\if :isaurora
+ \if :is_apg_plan_mgmt_not_enabled
+ \qecho 'Query Plan Management (QPM) is not enabled'
+ \else
+ \if :is_apg_plan_mgmt_enabled
+ show rds.enable_plan_management ;
+ SELECT e.extname AS "Extension Name", e.extversion AS "Version", n.nspname AS "Schema",pg_get_userbyid(e.extowner) as Owner, c.description AS "Description" , e.extrelocatable as "relocatable to another schema", e.extconfig ,e.extcondition
+ FROM pg_catalog.pg_extension e LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass
+ where e.extname = 'apg_plan_mgmt';
+ select * from pg_available_extensions where name='apg_plan_mgmt';
+ SELECT name ,version ,installed FROM pg_available_extension_versions where name='apg_plan_mgmt' order by version;
+ select name,setting from pg_settings where name like 'apg_plan_mgmt%';
+ with plans_stored_count as (select count(*) as cnt from apg_plan_mgmt.dba_plans)
+ select s.setting as max_plans, p.cnt as plans_stored_count, (p.cnt/s.setting::int)*100 as plans_stored_PCT_from_max_plans from pg_settings s, plans_stored_count p where s.name ='apg_plan_mgmt.max_plans';
+ \endif
+ \endif
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+-- +----------------------------------------------------------------------------+
+-- | - Aurora_dml_activity - |
+-- +----------------------------------------------------------------------------+
+\qecho
+\qecho Aurora dml activity
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+with dml_details as (
+SELECT db.datname AS datname,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 1), '()'),'') AS select_count,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 2), '()'),'') AS select_latency_microsecs,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 3), '()'),'') AS insert_count,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 4), '()'),'') AS insert_latency_microsecs,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 5), '()'),'') AS update_count,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 6), '()'),'') AS update_latency_microsecs,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 7), '()'),'') AS delete_count,
+ NULLIF(BTRIM(SPLIT_PART(db.asdmla::TEXT, ',', 8), '()'),'') AS delete_latency_microsecs
+ FROM (SELECT datname,
+ aurora_stat_dml_activity(oid) AS asdmla
+ FROM pg_database --where datname = 'rathoran_db'
+ ) AS db)
+select datname as database_name ,
+ select_count::numeric,
+ select_latency_microsecs::numeric,
+ TRUNC(select_latency_microsecs::numeric/NULLIF(select_count::numeric,0),3) select_latency_per_exec,
+ insert_count::numeric,
+ insert_latency_microsecs::numeric,
+ TRUNC(insert_latency_microsecs::numeric/NULLIF(insert_count::numeric,0),3) insert_latency_per_exec,
+ update_count::numeric,
+ update_latency_microsecs::numeric,
+ TRUNC(update_latency_microsecs::numeric/NULLIF(update_count::numeric,0),3) update_latency_per_exec,
+ delete_count::numeric,
+ delete_latency_microsecs::numeric,
+ TRUNC(delete_latency_microsecs::numeric/NULLIF(delete_count::numeric,0) ,3)delete_latency_per_exec
+ FROM dml_details
+ order by select_count desc;
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+-- +----------------------------------------------------------------------------+
+-- | - process_memory_context_usage - |
+-- +----------------------------------------------------------------------------+
+\qecho
+\qecho Process memory context usage
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+select count(*) > 0 isaurora1215plus FROM aurora_version() where replace(substring(aurora_version, 1, 5),'.','')::int >= '1215' \gset
+\if :isaurora1215plus
+\qecho
+\qecho The allocated memory for each memory context across all the processes ordered by allocated memory:
+\qecho
+select
+name, sum(allocated) as allocated_size_bytes,
+ pg_size_pretty(sum(allocated)) as allocated_size,
+ pg_size_pretty(sum(used)) as used_size,
+ trunc(sum(used)/sum(allocated)*100,2) as used_pct,
+ sum(instances) as instances_count
+ from aurora_stat_memctx_usage()
+ group by name
+ order by allocated_size_bytes desc;
+\qecho
+\qecho The top 50 porcess with the highest allocated memory:
+\qecho
+select
+pid, sum(allocated) as allocated_size_bytes ,pg_size_pretty(sum(allocated)) as allocated_size , pg_size_pretty(sum(used)) as used_size,
+trunc(sum(used)/sum(allocated)*100,2) as used_pct
+from aurora_stat_memctx_usage()
+group by pid order by allocated_size_bytes desc
+limit 50;
+
+\qecho
+\qecho The top 50 porcess with the highest allocated memory including process information in pg_stat_activity view:
+\qecho
+WITH memctx AS
+ (select
+pid, sum(allocated) as allocated_size_bytes ,pg_size_pretty(sum(allocated)) as allocated_size , pg_size_pretty(sum(used)) as used_size,
+trunc(sum(used)/sum(allocated)*100,2) as used_pct
+from aurora_stat_memctx_usage()
+group by pid order by allocated_size_bytes desc
+limit 50
+ )
+select *
+from pg_stat_activity ps
+INNER JOIN memctx ON ps.pid = memctx.pid
+order by memctx.allocated_size_bytes desc ;
+\qecho
+\qecho The top 50 processes with the highest allocated memory and the breakdown of their memory usage of each memory context:
+\qecho
+WITH memctx as
+(select
+pid, sum(allocated) as allocated_size_bytes
+from aurora_stat_memctx_usage()
+group by pid order by allocated_size_bytes desc
+limit 50 )
+select pid ,name , allocated as allocated_size_bytes ,pg_size_pretty(allocated) as allocated_size , pg_size_pretty(used) as used_size , instances as instances_count from aurora_stat_memctx_usage() where pid in
+(select pid from memctx )
+order by PID, allocated_size_bytes desc;
+\else
+ \if yes
+ \qecho 'aurora_stat_memctx_usage function is only available staring from Aurora PostgreSQL version 12.15'
+ \endif
+\endif
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+\qecho [Top]
+
+
+
+-- +----------------------------------------------------------------------------+
+-- | - logical_replication_write_through_cache - |
+-- +----------------------------------------------------------------------------+
+
+
+\qecho
+\qecho Logical replication write-through cache
+\qecho
+\qecho
+select count(*) > 0 isaurora from pg_settings where name='rds.extensions' and setting like '%aurora_stat_utils%' \gset
+\if :isaurora
+select count(*) > 0 isaurora1212plus FROM aurora_version() where replace(substring(aurora_version, 1, 5),'.','')::int >= '1212' \gset
+\if :isaurora1212plus
+SELECT * FROM aurora_stat_logical_wal_cache();
+\else
+ \if yes
+ \qecho 'aurora_stat_logical_wal_cache function is only available staring from Aurora PostgreSQL version 12.12'
+ \endif
+\endif
+\else
+ \if yes
+ \qecho 'This is not Aurora instance'
+ \endif
+\endif
+\qecho
+
+\qecho [Top]
+
+
+\echo Report Generated Successfully
+\echo Report name and location: /tmp/pg_collector_:filename.html
\q