Skip to content

Instantly share code, notes, and snippets.

schema | table | rowcount | dead_rowcount | autovacuum_threshold | expect_autovacuum | relfrozenxid_age | autovacuum_freeze_table_age | next_autovacuum_will_be_a_freeze | autovacuum_freeze_max_age | % til forced vacuum freeze
---------+---------+----------------+----------------+----------------------+-------------------+------------------+-----------------------------+----------------------------------+---------------------------+----------------------------
public | table01 | 1,336,112,512 | 4,641,856 | 267,222,552 | | 165311956 | 1.5e+08 | yes | 2e+08 | 82.7%
public | table02 | 777,657,088 | 20,662,775 | 155,531,468 | | 165311956 | 1.5e+08 | yes | 2e+08 | 82.7%
public | table03 | 642,018,368 | 9 | 128,403,724 | | 165311956 |
@skehlet
skehlet / gist:36aad599171b25826e82
Created May 6, 2015 17:45
Show autovacuum and analyze data, including if the next autovacuum will be a freeze; and how close the table is to being force-freezed
WITH table_opts AS (
SELECT
pg_class.oid, relname, nspname, array_to_string(reloptions, '') AS relopts
FROM
pg_class INNER JOIN pg_namespace ns ON relnamespace = ns.oid
), storage_settings AS (
SELECT
oid, relname, nspname,
CASE
WHEN relopts LIKE '%autovacuum_vacuum_threshold%'
function my_explode($delimiter, $string, $limit = null) {
$array = call_user_func_array('explode', func_get_args());
if (count($array) === 1 && strlen($array[0]) === 0) {
return array();
}
return $array;
}
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Redirecting...</title>
<link rel=canonical href="http://www.kehlet.cx/subnetting-is-fun/index.html">
<meta http-equiv=refresh content="0; url=http://www.kehlet.cx/subnetting-is-fun/index.html">
<h1>Redirecting...</h1>
<a href="http://www.kehlet.cx/subnetting-is-fun/index.html">Click here if you are not redirected.</a>
<script>location='http://www.kehlet.cx/subnetting-is-fun/index.html'</script>
import java.util.*;
import java.net.*;
public class ShowEth0PrimaryIp {
public static final String ETH0 = "eth0";
public static void main(String[] args) throws Exception {
System.out.println(new ShowEth0PrimaryIp().getEth0PrimaryIp());
}
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class ClassGenerator {
private List<Class<?>> classList = new ArrayList<>();
public static void main(String[] args) {
ckage com.vkg;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class ClassGenerator {
private static final int BUFFER = 1024;
postgres=# SELECT version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44), 64-bit
(1 row)
postgres=# SELECT name, current_setting(name), source
postgres-# FROM pg_settings
postgres-# WHERE source NOT IN ('default', 'override');
name | current_setting | source
TopMemoryContext: 123760 total in 16 blocks; 2720 free (7 chunks); 121040 used
TableSpace cache: 8192 total in 1 blocks; 3216 free (0 chunks); 4976 used
Type information cache: 24240 total in 2 blocks; 3744 free (0 chunks); 20496 used
Operator lookup cache: 24576 total in 2 blocks; 11888 free (5 chunks); 12688 used
TopTransactionContext: 8192 total in 1 blocks; 7368 free (0 chunks); 824 used
MessageContext: 4186112 total in 9 blocks; 633960 free (19 chunks); 3552152 used
JoinRelHashTable: 8192 total in 1 blocks; 624 free (0 chunks); 7568 used
Operator class cache: 8192 total in 1 blocks; 1680 free (0 chunks); 6512 used
smgr relation table: 24576 total in 2 blocks; 9808 free (4 chunks); 14768 used
TransactionAbortContext: 32768 total in 1 blocks; 32736 free (0 chunks); 32 used
mirthdb=> SELECT version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44), 64-bit
(1 row)
mirthdb=> SELECT name, current_setting(name), source
mirthdb-> FROM pg_settings
mirthdb-> WHERE source NOT IN ('default', 'override');
name | current_setting | source