Skip to content

Instantly share code, notes, and snippets.

View slardiere's full-sized avatar

Lardière Sébastien slardiere

View GitHub Profile
@slardiere
slardiere / seqscan.sql
Created October 20, 2020 15:06
Get Size of SeqScan data
-- 1- Data collect in a database, 2 times with few hours lag
-- 2- 'Create table as' in another database
-- CREATE TABLE stats_tables AS
\o tables.out
COPY (
SELECT relid , schemaname , relname , seq_scan
, seq_tup_read , idx_scan , idx_tup_fetch
, pg_table_size(relid) as table_size
, now() AS date_ev
@slardiere
slardiere / openssh.ps1
Last active February 7, 2022 22:31
Install OpenSSH on Windows
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
$url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/latest/'
$request = [System.Net.WebRequest]::Create($url)
@slardiere
slardiere / pg_streaming_lag
Last active December 27, 2015 14:19
Translate PostgreSQL Lag in bytes
-- Calculate From : http://munin-monitoring.org/browser/munin/plugins/node.d/postgres_streaming_.in
-- with help : http://www.postgresql.org/docs/9.3/static/monitoring-stats.html#PG-STAT-REPLICATION-VIEW
-- http://eulerto.blogspot.fr/2011/11/understanding-wal-nomenclature.html
create or replace function CalculateNumericalOffset(text)
returns bigint
language sql
as $$
select ('x'||lpad( 'ff000000', 16, '0'))::bit(64)::bigint
* ('x'||lpad( split_part( $1 ,'/',1), 16, '0'))::bit(64)::bigint