├── .gitignore ├── README.md ├── administration ├── copy-swap-drop.sql ├── edit_postgresql.conf.sh ├── int-bigint-investigations │ ├── explore_amount_free.sql │ └── explore_int_pk_tables.sql ├── pgbadger_log.sh ├── shared_buffers.sql └── tail_log.sh ├── approximate_count.sql ├── backfilling ├── 0-populate-riders.sql ├── 1-create-schema.sql ├── 2-create-table.sql ├── 3-insert-into-select-from.sql └── README.md ├── big_in_lists └── create_tables.sql ├── cache_hit_rate.sql ├── cancel_backend.sql ├── concurrent_index_build_progress.sql ├── constraint_definition_ddl.sql ├── create_index_create_statement.sql ├── detect_transaction_id_wraparound.sql ├── find_dbid_database_oid.sql ├── find_hot_updates.sql ├── find_indexed_columns_high_null_frac.sql ├── find_missing_indexes.sql ├── find_replica_identity.sql ├── find_unused_indexes.sql ├── find_unused_indexes_only.sql ├── foreign_keys.sql ├── generate_add_foreign_keys_ddl_to_target_table.sql ├── generate_data.sql ├── idle_sessions_count.sql ├── idle_transactions.sql ├── index_analysis_and_bloat_estimate.sql ├── index_size_usage_stats.sql ├── insert_only_pg_stat_user_tables.sql ├── last_tables_autovacuumed.sql ├── list_10_largest_tables.sql ├── list_10_worst_queries.sql ├── list_all_sequences.sql ├── list_all_sequences_column_owner.sql ├── list_collations.sql ├── list_comments.sql ├── list_db_views.sql ├── list_enums.sql ├── list_indexes.sql ├── list_long_running_queries.sql ├── list_partitioned_tables.sql ├── list_schemata.sql ├── list_single_column_multicolumn_index_counts.sql ├── list_table_object_dependencies.sql ├── list_tables_root_tables_no_fks.sql ├── list_tables_without_primary_key.sql ├── lock_blocking_waiting_pg_locks.sql ├── max_connection.sql ├── multiple_row_updates.sql ├── per_table_options_reloptions_all_regular_tables.sql ├── percent_not_null.sql ├── pg_stat_activity_pg_locks.sql ├── pg_stat_database.sql ├── pg_wait_sampling_queries.sql ├── pgbench_setup.sh ├── psql_csv_output.txt ├── public_transaction_ids └── create_and_use_functions.sql ├── random_between.sql ├── readonly_table.sql ├── relation_size.sql ├── relation_size_extended.sql ├── relation_size_partitions_estimates.sql ├── scrub_email.sql ├── scrub_email_batch.sql ├── show_server_version_num.sql ├── soft_deletes_detection.sql ├── stats_and_ratios.sql ├── table_bloat.sql ├── table_stats.sql ├── table_with_column.sql ├── tables_with_index_usage_counts.sql ├── terminate_backend.sql ├── top_10_tables_by_row_count.sql ├── top_10_tables_by_size.sql ├── top_updated_tables.sql ├── uuid_experiments ├── README.md ├── create_indexes.sql ├── create_tables.sql └── page_density.sql ├── vacuum_information_dead_tuples.sql ├── view_extensions.sql └── waiting_queries.sql /.gitignore: -------------------------------------------------------------------------------- 1 | administration/out.html 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/README.md -------------------------------------------------------------------------------- /administration/copy-swap-drop.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/copy-swap-drop.sql -------------------------------------------------------------------------------- /administration/edit_postgresql.conf.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/edit_postgresql.conf.sh -------------------------------------------------------------------------------- /administration/int-bigint-investigations/explore_amount_free.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/int-bigint-investigations/explore_amount_free.sql -------------------------------------------------------------------------------- /administration/int-bigint-investigations/explore_int_pk_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/int-bigint-investigations/explore_int_pk_tables.sql -------------------------------------------------------------------------------- /administration/pgbadger_log.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/pgbadger_log.sh -------------------------------------------------------------------------------- /administration/shared_buffers.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/shared_buffers.sql -------------------------------------------------------------------------------- /administration/tail_log.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/administration/tail_log.sh -------------------------------------------------------------------------------- /approximate_count.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/approximate_count.sql -------------------------------------------------------------------------------- /backfilling/0-populate-riders.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/backfilling/0-populate-riders.sql -------------------------------------------------------------------------------- /backfilling/1-create-schema.sql: -------------------------------------------------------------------------------- 1 | CREATE SCHEMA IF NOT EXISTS temp_backfill; 2 | 3 | -- \dn 4 | -------------------------------------------------------------------------------- /backfilling/2-create-table.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/backfilling/2-create-table.sql -------------------------------------------------------------------------------- /backfilling/3-insert-into-select-from.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/backfilling/3-insert-into-select-from.sql -------------------------------------------------------------------------------- /backfilling/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/backfilling/README.md -------------------------------------------------------------------------------- /big_in_lists/create_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/big_in_lists/create_tables.sql -------------------------------------------------------------------------------- /cache_hit_rate.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/cache_hit_rate.sql -------------------------------------------------------------------------------- /cancel_backend.sql: -------------------------------------------------------------------------------- 1 | SELECT pg_terminate_backend(123); 2 | -------------------------------------------------------------------------------- /concurrent_index_build_progress.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/concurrent_index_build_progress.sql -------------------------------------------------------------------------------- /constraint_definition_ddl.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/constraint_definition_ddl.sql -------------------------------------------------------------------------------- /create_index_create_statement.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/create_index_create_statement.sql -------------------------------------------------------------------------------- /detect_transaction_id_wraparound.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/detect_transaction_id_wraparound.sql -------------------------------------------------------------------------------- /find_dbid_database_oid.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_dbid_database_oid.sql -------------------------------------------------------------------------------- /find_hot_updates.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_hot_updates.sql -------------------------------------------------------------------------------- /find_indexed_columns_high_null_frac.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_indexed_columns_high_null_frac.sql -------------------------------------------------------------------------------- /find_missing_indexes.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_missing_indexes.sql -------------------------------------------------------------------------------- /find_replica_identity.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_replica_identity.sql -------------------------------------------------------------------------------- /find_unused_indexes.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_unused_indexes.sql -------------------------------------------------------------------------------- /find_unused_indexes_only.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/find_unused_indexes_only.sql -------------------------------------------------------------------------------- /foreign_keys.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/foreign_keys.sql -------------------------------------------------------------------------------- /generate_add_foreign_keys_ddl_to_target_table.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/generate_add_foreign_keys_ddl_to_target_table.sql -------------------------------------------------------------------------------- /generate_data.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/generate_data.sql -------------------------------------------------------------------------------- /idle_sessions_count.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/idle_sessions_count.sql -------------------------------------------------------------------------------- /idle_transactions.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/idle_transactions.sql -------------------------------------------------------------------------------- /index_analysis_and_bloat_estimate.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/index_analysis_and_bloat_estimate.sql -------------------------------------------------------------------------------- /index_size_usage_stats.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/index_size_usage_stats.sql -------------------------------------------------------------------------------- /insert_only_pg_stat_user_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/insert_only_pg_stat_user_tables.sql -------------------------------------------------------------------------------- /last_tables_autovacuumed.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/last_tables_autovacuumed.sql -------------------------------------------------------------------------------- /list_10_largest_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_10_largest_tables.sql -------------------------------------------------------------------------------- /list_10_worst_queries.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_10_worst_queries.sql -------------------------------------------------------------------------------- /list_all_sequences.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_all_sequences.sql -------------------------------------------------------------------------------- /list_all_sequences_column_owner.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_all_sequences_column_owner.sql -------------------------------------------------------------------------------- /list_collations.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_collations.sql -------------------------------------------------------------------------------- /list_comments.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_comments.sql -------------------------------------------------------------------------------- /list_db_views.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_db_views.sql -------------------------------------------------------------------------------- /list_enums.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_enums.sql -------------------------------------------------------------------------------- /list_indexes.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_indexes.sql -------------------------------------------------------------------------------- /list_long_running_queries.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_long_running_queries.sql -------------------------------------------------------------------------------- /list_partitioned_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_partitioned_tables.sql -------------------------------------------------------------------------------- /list_schemata.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_schemata.sql -------------------------------------------------------------------------------- /list_single_column_multicolumn_index_counts.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_single_column_multicolumn_index_counts.sql -------------------------------------------------------------------------------- /list_table_object_dependencies.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_table_object_dependencies.sql -------------------------------------------------------------------------------- /list_tables_root_tables_no_fks.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_tables_root_tables_no_fks.sql -------------------------------------------------------------------------------- /list_tables_without_primary_key.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/list_tables_without_primary_key.sql -------------------------------------------------------------------------------- /lock_blocking_waiting_pg_locks.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/lock_blocking_waiting_pg_locks.sql -------------------------------------------------------------------------------- /max_connection.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | (current_setting('max_connections')::numeric); 3 | 4 | -------------------------------------------------------------------------------- /multiple_row_updates.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/multiple_row_updates.sql -------------------------------------------------------------------------------- /per_table_options_reloptions_all_regular_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/per_table_options_reloptions_all_regular_tables.sql -------------------------------------------------------------------------------- /percent_not_null.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/percent_not_null.sql -------------------------------------------------------------------------------- /pg_stat_activity_pg_locks.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/pg_stat_activity_pg_locks.sql -------------------------------------------------------------------------------- /pg_stat_database.sql: -------------------------------------------------------------------------------- 1 | select * from pg_stat_database; 2 | -------------------------------------------------------------------------------- /pg_wait_sampling_queries.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/pg_wait_sampling_queries.sql -------------------------------------------------------------------------------- /pgbench_setup.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/pgbench_setup.sh -------------------------------------------------------------------------------- /psql_csv_output.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/psql_csv_output.txt -------------------------------------------------------------------------------- /public_transaction_ids/create_and_use_functions.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/public_transaction_ids/create_and_use_functions.sql -------------------------------------------------------------------------------- /random_between.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/random_between.sql -------------------------------------------------------------------------------- /readonly_table.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/readonly_table.sql -------------------------------------------------------------------------------- /relation_size.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/relation_size.sql -------------------------------------------------------------------------------- /relation_size_extended.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/relation_size_extended.sql -------------------------------------------------------------------------------- /relation_size_partitions_estimates.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/relation_size_partitions_estimates.sql -------------------------------------------------------------------------------- /scrub_email.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/scrub_email.sql -------------------------------------------------------------------------------- /scrub_email_batch.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/scrub_email_batch.sql -------------------------------------------------------------------------------- /show_server_version_num.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/show_server_version_num.sql -------------------------------------------------------------------------------- /soft_deletes_detection.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/soft_deletes_detection.sql -------------------------------------------------------------------------------- /stats_and_ratios.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/stats_and_ratios.sql -------------------------------------------------------------------------------- /table_bloat.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/table_bloat.sql -------------------------------------------------------------------------------- /table_stats.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/table_stats.sql -------------------------------------------------------------------------------- /table_with_column.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/table_with_column.sql -------------------------------------------------------------------------------- /tables_with_index_usage_counts.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/tables_with_index_usage_counts.sql -------------------------------------------------------------------------------- /terminate_backend.sql: -------------------------------------------------------------------------------- 1 | SELECT pg_cancel_backend(123); 2 | -------------------------------------------------------------------------------- /top_10_tables_by_row_count.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/top_10_tables_by_row_count.sql -------------------------------------------------------------------------------- /top_10_tables_by_size.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/top_10_tables_by_size.sql -------------------------------------------------------------------------------- /top_updated_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/top_updated_tables.sql -------------------------------------------------------------------------------- /uuid_experiments/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/uuid_experiments/README.md -------------------------------------------------------------------------------- /uuid_experiments/create_indexes.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/uuid_experiments/create_indexes.sql -------------------------------------------------------------------------------- /uuid_experiments/create_tables.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/uuid_experiments/create_tables.sql -------------------------------------------------------------------------------- /uuid_experiments/page_density.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/uuid_experiments/page_density.sql -------------------------------------------------------------------------------- /vacuum_information_dead_tuples.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/vacuum_information_dead_tuples.sql -------------------------------------------------------------------------------- /view_extensions.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/view_extensions.sql -------------------------------------------------------------------------------- /waiting_queries.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andyatkinson/pg_scripts/HEAD/waiting_queries.sql --------------------------------------------------------------------------------