Name | Last change | Commits | More actions | ||
---|---|---|---|---|---|
a421f972updated URLs Hari Sekhon | |||||
e11486ebupdated yaml.yaml Hari Sekhon | |||||
73153057updated bigquery_ml_classification_logistic_regression_predict_with_model2.sql Hari Sekhon | |||||
fa0a59caremoved setup/ci_git_set_dir_safe.sh Hari Sekhon | |||||
58ae406dadded .checkov.yaml Hari Sekhon | |||||
b60b975aupdated .editorconfig Hari Sekhon | |||||
f098c727updated .envrc Hari Sekhon | |||||
34599ce1added .envrc-python Hari Sekhon | |||||
71fa9843added .mdl.rb Hari Sekhon | |||||
7901a38fadded .mdlrc Hari Sekhon | |||||
6e4f333dupdated .pre-commit-config.yaml Hari Sekhon | |||||
819913f7updated URLs Hari Sekhon | |||||
a1b6071cupdated URLs Hari Sekhon | |||||
a050e744updated bigquery_billing_commonly_charged_units_of_measure.sql Hari Sekhon | |||||
1e6f6e0dupdated bigquery_billing_latest_100_charges.sql Hari Sekhon | |||||
d397751cupdated bigquery_billing_products_most_frequently_used.sql Hari Sekhon | |||||
f5aeca99updated bigquery_billing_products_with_highest_aggregate_cost.sql Hari Sekhon | |||||
00d91c4cupdated bigquery_billing_products_with_most_billing_records.sql Hari Sekhon | |||||
290217d2updated bigquery_info_biggest_public_tables_by_row_count.sql Hari Sekhon | |||||
3657a069updated bigquery_info_columns_partitioned_clustered.sql Hari Sekhon | |||||
ae48fab8updated bigquery_info_columns.sql Hari Sekhon | |||||
b1b3f67bupdated bigquery_info_datasets.sql Hari Sekhon | |||||
a1eabd87updated bigquery_info_tables.sql Hari Sekhon | |||||
0abec710updated LICENSE Hari Sekhon | |||||
a421f972updated URLs Hari Sekhon | |||||
ba181943updated mysql_databases_by_size.sql Hari Sekhon | |||||
017f9fbaupdated mysql_host_summary.sql Hari Sekhon | |||||
f4a17ae7updated mysql_indexes_unused.sql Hari Sekhon | |||||
151b4946updated mysql_info.sql Hari Sekhon | |||||
fad3c15aupdated mysql_memory_by_host.sql Hari Sekhon | |||||
7b1a1ec5updated mysql_memory_by_user.sql Hari Sekhon | |||||
e3b08d3aupdated mysql_sessions.sql Hari Sekhon | |||||
755a1830updated mysql_statement_latency_by_host.sql Hari Sekhon | |||||
8b3c3516updated mysql_statement_latency_by_user.sql Hari Sekhon | |||||
8de17975updated mysql_tables_nonsystem.sql Hari Sekhon | |||||
7ed52352updated mysql_tables.sql Hari Sekhon | |||||
d833585bupdated mysql_user_summary.sql Hari Sekhon | |||||
c9fc8f9eupdated mysql_user.sql Hari Sekhon | |||||
38464542updated mysql_users_pre56.sql Hari Sekhon | |||||
ab1ebb6bupdated mysql_users_pre8.sql Hari Sekhon | |||||
0e717c81updated mysql_users.sql Hari Sekhon | |||||
24b136a4updated mysql_views_system.sql Hari Sekhon | |||||
dc0547edupdated mysql_views.sql Hari Sekhon | |||||
99551091updated oracle_checkpoints.sql Hari Sekhon | |||||
cd2f8155added oracle_datafiles_checkpoint_change.sql Hari Sekhon | |||||
f6087ad2renamed oracle_checkpoint_datafiles.sql to oracle_datafiles_checkpoint_time.sql Hari Sekhon | |||||
126a606dadded oracle_datafiles_lastchanged.sql Hari Sekhon | |||||
47e2e7afadded oracle_datafiles_unrecoverable_change.sql Hari Sekhon | |||||
290ea56eadded oracle_user_sid_serial_status.sql Hari Sekhon | |||||
e6b73070updated postgres_active_query_count.sql Hari Sekhon | |||||
c3801858updated postgres_backends_per_database.sql Hari Sekhon | |||||
c54208fcupdated postgres_blocked_queries.sql Hari Sekhon | |||||
746212f5updated postgres_columns_null.sql Hari Sekhon | |||||
b41758caupdated postgres_columns_useless.sql Hari Sekhon | |||||
9eb66a3cupdated postgres_databases_by_size_if_accessible.sql Hari Sekhon | |||||
a65755deupdated postgres_databases_by_size.sql Hari Sekhon | |||||
1434ac7cupdated postgres_dirs_pre10.sql Hari Sekhon | |||||
f09011f2updated postgres_dirs_pre11.9.sql Hari Sekhon | |||||
3d5ea068updated postgres_dirs.sql Hari Sekhon | |||||
4c4ef518updated postgres_grant_select_all_tables.sql Hari Sekhon | |||||
4b0722cbupdated postgres_idle_sessions_current_db_kill_pre92.sql Hari Sekhon | |||||
ba1d84bbupdated postgres_idle_sessions_current_db_kill.sql Hari Sekhon | |||||
60e4bd68updated postgres_idle_sessions_kill.sql Hari Sekhon | |||||
1f36eda4updated postgres_idle_sessions_pre92.sql Hari Sekhon | |||||
2b8f367fupdated postgres_idle_sessions.sql Hari Sekhon | |||||
e1ddebdeupdated postgres_index_cardinality_with_schema_name.sql Hari Sekhon | |||||
752ba82dupdated postgres_index_cardinality.sql Hari Sekhon | |||||
61dab0b9updated postgres_indexes_cache_hit_ratio.sql Hari Sekhon | |||||
87457e33updated postgres_indexes_unused.sql Hari Sekhon | |||||
2a8c14deupdated postgres_info_pre10.sql Hari Sekhon | |||||
f071662eupdated postgres_info.sql Hari Sekhon | |||||
46eb2bcaupdated postgres_last_analyze_pre94.sql Hari Sekhon | |||||
913961b2updated postgres_last_analyze.sql Hari Sekhon | |||||
09b69f4bupdated postgres_last_vacuum_analyze_pre94.sql Hari Sekhon | |||||
29f7b037updated postgres_last_vacuum_analyze.sql Hari Sekhon | |||||
651baae4updated postgres_last_vacuum_pre91.sql Hari Sekhon | |||||
de70dcadupdated postgres_last_vacuum.sql Hari Sekhon | |||||
3af29450updated postgres_locks_blocked_application.sql Hari Sekhon | |||||
12996f6aupdated postgres_locks_blocked.sql Hari Sekhon | |||||
bedc38c7updated postgres_locks_query_age_pre92.sql Hari Sekhon | |||||
825c09f1updated postgres_locks_query_age.sql Hari Sekhon | |||||
26ca9d64updated postgres_locks.sql Hari Sekhon | |||||
29b0e40aupdated postgres_queries_slow_pre92.sql Hari Sekhon | |||||
4fd964b0updated postgres_queries_slow_pre96.sql Hari Sekhon | |||||
5d07c98bupdated postgres_queries_slow.sql Hari Sekhon | |||||
fef4b93aupdated postgres_query_cache_hit_ratio.sql Hari Sekhon | |||||
af5b737eupdated postgres_query_times_pre13.sql Hari Sekhon | |||||
2085d5f7updated postgres_query_times_pre95.sql Hari Sekhon | |||||
48011266updated postgres_query_times.sql Hari Sekhon | |||||
eba185abupdated postgres_recovery.sql Hari Sekhon | |||||
d249e7f3updated postgres_running_queries_pre92.sql Hari Sekhon | |||||
804eeef3updated postgres_running_queries.sql Hari Sekhon | |||||
b64c445fupdated postgres_sequences_restart_all.sql Hari Sekhon | |||||
ceb6970aupdated postgres_sessions_pre10.sql Hari Sekhon | |||||
bc0eccadupdated postgres_sessions_state_count.sql Hari Sekhon | |||||
22f47a9fupdated postgres_sessions.sql Hari Sekhon | |||||
0c955ca1updated postgres_settings_auth.sql Hari Sekhon | |||||
ebcce200updated postgres_settings_autovacuum.sql Hari Sekhon | |||||
0bd74069updated postgres_settings_client_connection.sql Hari Sekhon | |||||
f4edb2b4updated postgres_settings_compatibility.sql Hari Sekhon | |||||
967f0e4fupdated postgres_settings_connections.sql Hari Sekhon | |||||
06a0fba6updated postgres_settings_developer.sql Hari Sekhon | |||||
b09e923bupdated postgres_settings_error_handling.sql Hari Sekhon | |||||
c1232325updated postgres_settings_files.sql Hari Sekhon | |||||
e32962aaupdated postgres_settings_locking.sql Hari Sekhon | |||||
54e43261updated postgres_settings_logging.sql Hari Sekhon | |||||
714e2a05updated postgres_settings_memory.sql Hari Sekhon | |||||
1b9ce729updated postgres_settings_misc.sql Hari Sekhon | |||||
22a06d52updated postgres_settings_preset.sql Hari Sekhon | |||||
90991205updated postgres_settings_query_planning.sql Hari Sekhon | |||||
1536f170updated postgres_settings_replication.sql Hari Sekhon | |||||
dcd97b55updated postgres_settings_resources.sql Hari Sekhon | |||||
133509b6updated postgres_settings_ssl.sql Hari Sekhon | |||||
688210fdupdated postgres_settings_statistics.sql Hari Sekhon | |||||
a586d2c0updated postgres_settings_wal.sql Hari Sekhon | |||||
24d51a7bupdated postgres_settings.sql Hari Sekhon | |||||
10dc2e2aupdated postgres_tables_by_size_2.sql Hari Sekhon | |||||
8cf455b6updated postgres_tables_by_size.sql Hari Sekhon | |||||
b8d1c95cupdated postgres_tables_cache_hit_ratio.sql Hari Sekhon | |||||
2946c3e8updated postgres_tables_index_usage.sql Hari Sekhon | |||||
36796b8bupdated postgres_tables_row_estimates.sql Hari Sekhon | |||||
b30bede5updated README Hari Sekhon | |||||
a1b6071cupdated URLs Hari Sekhon | |||||
SQL Scripts
Useful SQL scripts, split from DevOps Bash tools , for which this is now a submodule.
Hari Sekhon
Cloud & Big Data Contractor, United Kingdom
(you're welcome to connect with me on LinkedIn)
Inventory
DevOps / DBA
aws_athena_cloudtrail_ddl.sql
- AWS Athena DDL to setup up integration to query CloudTrail logs from Athenabigquery_*.sql
- Google BigQuery scripts:bigquery_billing_*.sql
- billing queries for GCP usage eg. highest cost services, most used GCP products, recent charges etc.bigquery_info_*.sql
- information schema queries for datasets, tables, columns, partitioning, clustering etc.
mysql_*.sql
:postgres_*.sql
:- PostgreSQL queries for DBA investigating + performance tuning
- postgres_info.sql - big summary overview, recommend you start here
- tested on PostgreSQL 8.4, 9.x, 10.x, 11.x, 12.x, 13.x
Analytics
bigquery_*.sql
- Google BigQuery scripts:bigquery_billing_*.sql
- billing queries for GCP usage eg. highest cost services, most used GCP products, recent charges etc.bigquery_info_*.sql
- information schema queries for datasets, tables, columns, partitioning, clustering etc.- analytics/
bigquery_*.sql
- ecommerce queries and BigQuery ML machine learning classification logistic regression models and purchasing predictions - for more BigQuery examples, see Data Engineering demos
DevOps SQL tooling
You can quickly test the PostgreSQL / MySQL scripts using postgres.sh
/ mysqld.sh
/ mariadb.sh
in the DevOps Bash tools repo, which boots a docker container and drops straight in to a mysql
/ psql
shell with this directory mounted at /sql
and used as $PWD
for fast easy sourcing eg.
postgres:
\i /sql/postgres_query_times.sql
\i postgres_query_times.sql
mysql:
source /sql/mysql_sessions.sql
\. mysql_sessions.sql
Related scripts
- .psqlrc - advanced PostgreSQL psql client config
- psql.sh - quickly connect to PostgreSQL with command line switches inferred from environment variables
- mysql.sh - quickly connect to MySQL / MariaDB with command line switches inferred from environment variables
- postgres.sh - one-touch PostgreSQL, boots docker container and drops you in to
psql
shell. Version can be given as an argument - mysqld.sh / mariadb.sh - one-touch MySQL / MariaDB, boots docker container and drops you in to
mysql
shell. Version can be given as an argument - postgres_foreach_table.sh / mysql_foreach_table.sh - execute templated SQL queries/statements against all or a subset of tables
- postgres_tables_row_counts.sh / mysql_tables_row_counts.sh - get row counts for all or a subset of tables
- sqlcase.pl - autocases your SQL code
- I use this a lot and call it via hotkey configured in my .vimrc
- there are
*case.pl
specializations for most of the major RDBMS and distributed SQL systems, even several NoSQL systems, using each one's language specific keywords
- Hive & Impala SQL:
- beeline.sh - quickly connect to Hive, auto-determines HiveServer2 address, Kerberos & SSL options, ZooKeeper quorum
- impala_shell.sh - quickly connect to Impala, auto-determines a Hadoop worker node address and Kerberos options (can use an environment variable for a Load Balancer setup)
- hive_foreach_table.sh / impala_foreach_table.sh - execute templated SQL queries/statements against all or a subset of tables
- hive_tables_row_counts.sh / impala_tables_row_counts.sh - get row counts for all or a subset of tables
- hive_tables_column_counts.sh / impala_tables_column_counts.sh - get the column counts for big tables in Hive / Impala
- hive_tables_metadata.sh / impala_tables_metadata.sh / hive_tables_locations.sh / impala_tables_locations.sh - get Hive / Impala metadata for all or a subset of tables, eg. Location to determine where the external tables data is being stored (HDFS / S3 paths)
Stargazers over time
More Core Repos
Knowledge
DevOps Code
Containerization
CI/CD
DBA - SQL
DevOps Reloaded
Templates
Misc
The rest of my original source repos are here .
Pre-built Docker images are available on my DockerHub .