This file contains hidden or 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
#!/bin/bash | |
# PS Running in CRON mode - meaning output produced only on errors | |
# Expected inputs: | |
# 1) the pgbackrest config file path, e.g. /etc/pgbackrest/15/main/pgbackrest.conf | |
# 2) the stanza name | |
# 3) max age threshold in seconds of last valid backup. | |
# errors if no valid backup within the threshold |
This file contains hidden or 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
#!/bin/bash | |
set -euo pipefail | |
SCALE=1200 | |
FF=80 | |
UNLOGGED="unlogged" # set to "" for normal tables | |
UNLOGGED="" | |
ROW_CHANGES=100000 # 0.1% of scale 1000 |
This file contains hidden or 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
import psycopg | |
import random | |
import time | |
CONNSTR = "postgresql://james:[email protected]:5432/postgres?sslmode=require" | |
SCALE = 10 | |
BASE_SQL = """ | |
BEGIN; | |
SELECT abalance FROM pgbench_accounts WHERE aid = {aid}; | |
SELECT abalance FROM pgbench_accounts WHERE aid = {aid2}; |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import time | |
import psycopg | |
from psycopg.rows import dict_row | |
from datetime import datetime | |
CONNSTR = "dbname=postgres user=postgres port=5434" |
This file contains hidden or 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
\set QUIET on | |
\pset linestyle unicode | |
\pset null ¤ | |
;\set PROMPT1 '%n@%/=%#%x ' | |
\pset pager on | |
\x auto | |
\set HISTCONTROL ignoreboth | |
\set HISTSIZE 10000 | |
\set HISTFILE ~/.psql_history- :DBNAME | |
\set PSQL_EDITOR 'vim -c ":set ft=sql"' |
This file contains hidden or 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
/* ON PROD DB */ | |
CREATE TEMP TABLE exported_stats AS | |
select | |
schemaname, | |
tablename, | |
attname, | |
null_frac, | |
avg_width, | |
n_distinct, |
This file contains hidden or 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
-- | |
-- PostgreSQL database dump | |
-- | |
-- Dumped from database version 17.4 (Ubuntu 17.4-1.pgdg24.04+2) | |
-- Dumped by pg_dump version 17.4 (Ubuntu 17.4-1.pgdg24.04+2) | |
SET statement_timeout = 0; | |
SET lock_timeout = 0; | |
SET idle_in_transaction_session_timeout = 0; |
This file contains hidden or 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
region | country | year | production | consumption | |
---|---|---|---|---|---|
North America | USA | 1965 | 9014 | 11522 | |
North America | USA | 1966 | 9579 | 12100 | |
North America | USA | 1967 | 10219 | 12567 | |
North America | USA | 1968 | 10600 | 13405 | |
North America | USA | 1969 | 10828 | 14153 | |
North America | USA | 1970 | 11297 | 14710 | |
North America | USA | 1971 | 11156 | 15223 | |
North America | USA | 1972 | 11185 | 16381 | |
North America | USA | 1973 | 10946 | 17318 |
This file contains hidden or 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
--- DROP TABLE IF EXISTS customer, product, payment_method, "order", order_item CASCADE ; | |
CREATE TABLE customer ( | |
customer_id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, | |
name TEXT NOT NULL, | |
dob DATE NOT NULL, | |
email TEXT UNIQUE NOT NULL, | |
created_on TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP | |
); |
This file contains hidden or 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
100 | Steven | King | SKING | 515.123.4567 | 2003-06-17 | AD_PRES | 24000.00 | 90 | |||
---|---|---|---|---|---|---|---|---|---|---|---|
101 | Neena | Kochhar | NKOCHHAR | 515.123.4568 | 2005-09-21 | AD_VP | 17000.00 | 100 | 90 | ||
102 | Lex | De Haan | LDEHAAN | 515.123.4569 | 2001-01-13 | AD_VP | 17000.00 | 100 | 90 | ||
103 | Alexander | Hunold | AHUNOLD | 590.423.4567 | 2006-01-03 | IT_PROG | 9000.00 | 102 | 60 | ||
104 | Bruce | Ernst | BERNST | 590.423.4568 | 2007-05-21 | IT_PROG | 6000.00 | 103 | 60 | ||
105 | David | Austin | DAUSTIN | 590.423.4569 | 2005-06-25 | IT_PROG | 4800.00 | 103 | 60 | ||
106 | Valli | Pataballa | VPATABAL | 590.423.4560 | 2006-02-05 | IT_PROG | 4800.00 | 103 | 60 | ||
107 | Diana | Lorentz | DLORENTZ | 590.423.5567 | 2007-02-07 | IT_PROG | 4200.00 | 103 | 60 | ||
108 | Nancy | Greenberg | NGREENBE | 515.124.4569 | 2002-08-17 | FI_MGR | 12008.00 | 101 | 100 | ||
109 | Daniel | Faviet | DFAVIET | 515.124.4169 | 2002-08-16 | FI_ACCOUNT | 9000.00 | 108 | 100 |
NewerOlder