- queryid in log_min_duration_statement
- queryid generation in core instead of contrib/pg_stat_statements
- pg_stat_plans in contrib (think of pg_stat_statements + auto_explain, possibly just store the EXPLAIN output as the text)
- pg_stat_statements in core
- pg_stat_statements should have idx_scan and seq_scan counters
- changefeeds (aka logical decoding for realtime updates, instead of LISTEN/NOTIFY)
- JSON logical decoder in core
- COPY from URL / Make COPY extendable (so there can be an S3 handler)
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
[ignore] | |
.*node_modules/react-apollo/.* |
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
DO LANGUAGE plpgsql $$ | |
DECLARE | |
t record; | |
tables text[]; | |
BEGIN | |
FOR t IN SELECT schemaname, tablename FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') LOOP | |
tables := array_append(tables, quote_ident(t.schemaname) || '.' || quote_ident(t.tablename)); | |
END LOOP; | |
IF array_length(tables, 1) > 0 THEN |
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
# Put this in config/initializers/copy_from_client.rb | |
class CopyFromClientHelper | |
attr_reader :count | |
def initialize(conn, column_types) | |
@count = 0 | |
@conn = conn | |
@column_types = column_types | |
end |
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
require 'pg_query' | |
pp PgQuery.parse("SELECT * FROM x WHERE y = ?") | |
#<PgQuery:0x007f8cdaaaae10 | |
@parsetree= | |
[{"SELECT"=> | |
{"distinctClause"=>nil, | |
"intoClause"=>nil, | |
"targetList"=> | |
[{"RESTARGET"=> |
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
#my_orm_method("1") | |
1 | |
#my_orm_method("'abc'") | |
abc | |
#my_orm_method("1 UNION SELECT * FROM passwords") | |
test.rb:8:in `exec_with_fingerprint': Invalid fingerprint, rejecting (RuntimeError) | |
from test.rb:16:in `my_orm_method' | |
from test.rb:23:in `<main>' |
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
# Analyzes all distributed tables | |
export PGHOST=... | |
export PGUSER=citus | |
export PGPASSWORD=... | |
#export PGSSLMODE=require | |
export PGDATABASE=citus | |
export PARALLEL_FACTOR=4 | |
psql -tA -F" " -c "SELECT logicalrelid::regclass||'_'||s.shardid, \ |
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
# Place this in app/models/concerns/fix_composite_key_insert.rb | |
# Fix for https://github.com/composite-primary-keys/composite_primary_keys/issues/365 | |
# | |
# Act as if the record has a single primary key column in some cases, in | |
# particular when we get called from _create_record with the RETURNING result: | |
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/persistence.rb#L560 | |
module FixCompositeKeyInsert | |
extend ActiveSupport::Concern |
First, we'll need to place a few files in the right location:
curl -o /usr/bin/pganalyze-collector https://github.com/pganalyze/collector/releases/download/v0.9.4/pganalyze-collector-linux-amd64
curl -o /etc/systemd/system/pganalyze-collector.service https://github.com/pganalyze/collector/blob/master/contrib/systemd/pganalyze-collector.service
curl -o /etc/pganalyze-collector.conf https://github.com/pganalyze/collector/blob/master/contrib/pganalyze-collector.conf
In addition, run the following commands:
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 | |
size_bytes AS table_size, | |
(SELECT SUM(size_bytes) FROM schema_index_stats sis JOIN schema_indices si ON (si.id = sis.schema_index_id) WHERE si.table_id = st.schema_table_id AND sis.snapshot_id = st.snapshot_id) AS index_size, | |
COALESCE((SELECT SUM(size_bytes) FROM schema_indices si JOIN schema_index_stats sis ON (si.id = sis.schema_index_id) WHERE si.table_id = st.schema_table_id AND sis.snapshot_id = st.snapshot_id), ?) + size_bytes AS total_size, | |
date_part(?, s.collected_at) AS collected_at | |
FROM | |
snapshots s JOIN schema_table_stats st | |
ON | |
(snapshot_id = s.id) | |
WHERE |