-- This function increases the DB size upto `minimum_db_size` by cloning the `source_schema` into a new name `dest_schema_<dynamic_count>`
CREATE OR REPLACE FUNCTION increase_db_size_upto(source_schema text, dest_schema text, minimum_db_size int, multiplier_factor int)
RETURNS void AS
$BODY$
DECLARE
objeto record;
buffer text;
db_size int;
schema_count int;
-- Usage: SELECT truncate_all_tables_in_schemas(ARRAY['schema1', 'schema2', 'schema3']);
CREATE OR REPLACE FUNCTION truncate_all_tables_in_schemas(schema_names text[]) RETURNS void AS $$
DECLARE
schema_name text;
table_name text;
BEGIN
FOREACH schema_name IN ARRAY schema_names
LOOP
FOR table_name IN (SELECT tablename FROM pg_tables WHERE schemaname = schema_name)
CREATE OR REPLACE FUNCTION table_rows(tables text[])
RETURNS TABLE (table_name text, count bigint) AS $$
DECLARE
query text := '';
BEGIN
FOR i IN 1..array_length(tables, 1) LOOP
query := query || format('SELECT %L as table_name, count(*) from %s', tables[i], tables[i]);
IF i < array_length(tables, 1) THEN
query := query || ' union all ';
sudo apt-get install build-essential \
libgc-dev \
libselinux-dev \
libzstd-dev \
liblz4-dev \
libxslt-dev \
libpam-dev \
libz-dev \
libreadline-dev \
This Gist implements the migration-eval Python script in PSQL, allowing the script to run without the need for Python.
Steps:
- Copy the script below to a
evaluate.sql
file. - To run:
psql -t -q -d "<URI>" -f evaluate.sql > report.txt
Note:
- The script should complete running within 5 minutes. If it takes longer (due to a lock that can occur when the production load is high), you can decrease the value of
\set wait_duration 60
from60
to30
. If decreasing the value does not help, you can share the output ofreport.txt
as is.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"os" | |
"github.com/jackc/pgx/v5" | |
) |
OlderNewer