I couldn't find this link when searching with google
https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresql
I couldn't find this link when searching with google
https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresql
SELECT pg_current_xlog_location();[Run on replica] Check replica replayed location with
SELECT pg_last_xlog_replay_location();[Run on master] Check replica status from master
SELECT client_addr, state, sent_location, write_location, flush_location, replay_location FROM pg_stat_replication;*write, flush, replay are status of replica
SELECT now() - pg_last_xact_replay_timestamp() AS replication_delay;Credit:
# SELECT * FROM pg_stat_user_indexes ORDER BY idx_scan DESC;If your database is manage by Rails's schema, you could filter out auto generated public key indexes like so
# SELECT * FROM pg_stat_user_indexes WHERE indexrelname NOT LIKE '%_pkey' ORDER BY idx_scan DESC;
If we had a composite index on three fields: we would be able to use it for queries on the first field, for queries on the first two fields and for queries involving all three fields, but not on any other field combination.Copied directly from How to stop worrying and love your Postgres indexes
You might also what to order the result by query_start or state_changeselect * from pg_stat_activity where datname = YOUR_DB_NAME and state = 'active'
log_statement = 'all'2. To reload config, sending SIGHUP to postgres server by going to psql shell and execute:
select pg_reload_conf();There's an another way to send SIGHUP, please refer to the link below
=# CREATE DATABASE new_database_name WITH TEMPLATE original_database_name;
$ createdb -T original_database_name new_database_nameCredit: http://stackoverflow.com/a/6739995
cpg_dump: Dumping the contents of table "[table_name]" failed: PQgetResult() failed.I turns out that we can't execute long query on Hot Standby mode server. Right now, there's no perfect solution to this problem but there are some couples of workarounds.
pg_dump: Error message from server: ERROR: canceling statement due to conflict with recovery
DETAIL: User query might have needed to see row versions that must be removed.
pg_dump: The command was: COPY public.[table_name] ([comma-separated column names]) TO stdout;
$ psql -h 10.0.1.11 dbname
psql: could not connect to server: Connection refused
Is the server running on host "10.0.1.11" and accepting
TCP/IP connections on port 5432?
pg_dump <src_database_name> -s > schema.sql(Optional) Use -t to specify table. For more than 1 table just add more -t.
pg_dump <src_database_name> -s -t <table1_name> -t <table2_name> > schema.sql
psql <dest_database_name> -f schema.sql
I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...