https://github.com/AdmTal/PostgreSQL-Query-Lock-Explainer Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} AdmTal / PostgreSQL-Query-Lock-Explainer Public * Notifications * Fork 1 * Star 25 Command line utility to show what locks will be acquired by a given query. License MIT license 25 stars 1 fork Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights AdmTal/PostgreSQL-Query-Lock-Explainer This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/A] Use Git or checkout with SVN using the web URL. [gh repo clone AdmTal] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit Adam Tal mistakes ... 16fc1f0 Oct 31, 2019 mistakes 16fc1f0 Git stats * 8 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .gitignore Make pip installable October 31, 2019 11:14 LICENSE Make pip installable October 31, 2019 11:14 README.md mistakes October 31, 2019 11:32 pg_explain_locks.py Safety first October 31, 2019 11:24 requirements.txt Explain query October 26, 2019 21:06 setup.py mistakes October 31, 2019 11:32 View code PostgreSQL Query Lock Explainer Installation instructions Example Usage Example usage with settings file README.md PostgreSQL Query Lock Explainer Utility to show what locks will be acquired by a given query. Query is executed but not committed. Installation instructions pip install pg_explain_locks Example Usage Examples shown against dvdrental sample database pg_explain_locks \ --user DB_USER \ --password DB_PASSWORD \ --database DATABASE \ --host HOST \ --query "DROP table actor CASCADE" +-------------+----------------------------+---------------------+ | Relation ID | Relation Name | Lock Type | +-------------+----------------------------+---------------------+ | 16422 | actor | AccessExclusiveLock | | 16448 | film_actor | AccessExclusiveLock | | 16456 | actor_info | AccessExclusiveLock | | 16487 | film_list | AccessExclusiveLock | | 16506 | nicer_but_slower_film_list | AccessExclusiveLock | | 16557 | actor_pkey | AccessExclusiveLock | | 16588 | idx_actor_last_name | AccessExclusiveLock | +-------------+----------------------------+---------------------+ pg_explain_locks \ --user DB_USER \ --password DB_PASSWORD \ --database DATABASE \ --host HOST \ --query "SELECT * FROM film_actor fa JOIN actor a on a.actor_id=fa.actor_id FOR UPDATE" +-------------+---------------------+-----------------+ | Relation ID | Relation Name | Lock Type | +-------------+---------------------+-----------------+ | 16422 | actor | RowShareLock | | 16448 | film_actor | RowShareLock | | 16557 | actor_pkey | AccessShareLock | | 16569 | film_actor_pkey | AccessShareLock | | 16588 | idx_actor_last_name | AccessShareLock | | 16593 | idx_fk_film_id | AccessShareLock | +-------------+---------------------+-----------------+ pg_explain_locks \ --user DB_USER \ --password DB_PASSWORD \ --database DATABASE \ --host HOST \ --query "ALTER TABLE customer ADD COLUMN deleted BOOLEAN" +-------------+---------------+---------------------+ | Relation ID | Relation Name | Lock Type | +-------------+---------------+---------------------+ | 16411 | customer | AccessExclusiveLock | +-------------+---------------+---------------------+ Example usage with settings file Create a settings file at ~/.pg_explain_locks_settings in order to use the same DB settings every time. Settings file contents : USER=your_user PASSWORD=your_password DATABASE=your_database HOST=your_host PORT=your_post Usage: pg_explain_locks "ALTER TABLE customer ADD COLUMN deleted BOOLEAN" +-------------+---------------+---------------------+ | Relation ID | Relation Name | Lock Type | +-------------+---------------+---------------------+ | 16411 | customer | AccessExclusiveLock | +-------------+---------------+---------------------+ About Command line utility to show what locks will be acquired by a given query. Resources Readme License MIT license Stars 25 stars Watchers 2 watching Forks 1 fork Report repository Releases No releases published Packages 0 No packages published Languages * Python 100.0% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.