PostgreSQL Query Lock Explainer

Dev tools

database query analysis

SHOW HN2023

143points
14comments
#443of 3,109 in 2023
Top 15%of 2023 by points

How HN took it

CuriousMostly questions and neutral comments

1 positive, 3 neutral or asking, 0 mixed, 2 critical, out of 6 comments about the project. Thread score -0.13.

Docs: 0 for, 1 againstDesign: 1 for, 0 againstExecution: 0 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Useful tool for checking migration locks

    From 2 comments
    • Neat tool! I prefer using environment variables for my connection info to avoid passwords in my shell history or plaintext config files. The standard[1] ones from libpq work in…
      efxhoy on HN
    • Link to relevant source code: https://github.com/AdmTal/PostgreSQL-Query-Lock-Explainer/blob/da1c5fcfe7b1d5f8755c0203ad66ea0e3828c00f/pg_explain_locks.py#L148-L153
      runeks on HN

Objections

  • Executes the query to find locks, which is risky for long or non-transactional statements

    From 2 comments
    • It would be nice if you added a how it works section to the readme. Knowing that it does `begin; $ {query}; rollback;` under the hood is important. The example with truncate in…
      fovc on HN
    • Not a postgres expert, but it looks like this is checked by executing the query: https://github.com/AdmTal/PostgreSQL-Query-Lock-Explainer/blob/master/pg_explain_locks.py#L60…
      hn92726819 on HN
  • Docs don't explain the begin/rollback approach

    From 1 comment
    • It would be nice if you added a how it works section to the readme. Knowing that it does `begin; $ {query}; rollback;` under the hood is important. The example with truncate in…
      fovc on HN

Requests

  • Add a how-it-works section to the README

    From 1 comment
    • It would be nice if you added a how it works section to the readme. Knowing that it does `begin; $ {query}; rollback;` under the hood is important. The example with truncate in…
      fovc on HN
  • Warn about statements that cannot be rolled back

    From 1 comment
    • Maybe emitting a warning would be good. I'm no DBA so remembering all operations that cannot be rolledback might be tough. (Though maybe I should know all of them if they aren't…
      mad0 on HN
  • Support environment variables for connection settings

    From 1 comment
    • Neat tool! I prefer using environment variables for my connection info to avoid passwords in my shell history or plaintext config files. The standard[1] ones from libpq work in…
      efxhoy on HN

Questions

  • Are locks taken by trigger functions included?

    From 1 comment
    • If the query causes a trigger to fire, will any additional locks that are created by the trigger(s) (that is, any functions called by the triggers) be noted?
      irrational on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/35981238)