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
1. createdb test | |
2. ./schema.sh > schema.sql | |
3. ./data.sh > data.sql | |
4. psql test < schema.sql | |
5. psql test < data.sql | |
6. Reproduce the problem | |
SELECT id into agg | |
FROM "content" | |
WHERE "content"."id" IN |
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
from string import Template | |
from distutils.util import strtobool | |
from flask import Flask, request | |
from flask.ext.restful import Api, Resource | |
import psycopg2 | |
# Flask-RESTful Api object | |
app = Flask(__name__) |
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
CREATE OR REPLACE VIEW bloat AS | |
SELECT | |
schemaname, tablename, reltuples::bigint, relpages::bigint, otta, | |
ROUND(CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages/otta::numeric END,1) AS tbloat, | |
relpages::bigint - otta AS wastedpages, | |
bs*(sml.relpages-otta)::bigint AS wastedbytes, | |
pg_size_pretty((bs*(relpages-otta))::bigint) AS wastedsize, | |
iname, ituples::bigint, ipages::bigint, iotta, | |
ROUND(CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages/iotta::numeric END,1) AS ibloat, | |
CASE WHEN ipages < iotta THEN 0 ELSE ipages::bigint - iotta END AS wastedipages, |
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
SELECT relation, | |
total_size, | |
relation_size, | |
indexes_size, | |
count | |
FROM | |
(SELECT nspname || '.' || relname AS "relation", | |
pg_size_pretty(pg_total_relation_size(C.oid) + COALESCE(partitions_info.total_size, 0)) AS "total_size", | |
pg_size_pretty(pg_relation_size(C.oid) + COALESCE(partitions_info.relation_size, 0)) AS "relation_size", | |
pg_size_pretty(pg_total_relation_size(C.oid) + COALESCE(partitions_info.total_size, 0) - pg_relation_size(C.oid) - COALESCE(partitions_info.relation_size, 0)) AS "indexes_size", |
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
A Postgres Receipts |
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
1. pip install -r reqs.pip | |
2. server.py | |
3. open client.html in browser | |
4. redis-cli publish push '123456' | |
5. check browser console |