logoalt Hacker News

Show HN: SQL-tap – Real-time SQL traffic viewer for PostgreSQL and MySQL

105 pointsby mickamytoday at 4:27 AM18 commentsview on HN

sql-tap is a transparent proxy that captures SQL queries by parsing the PostgreSQL/MySQL wire protocol and displays them in a terminal UI. You can run EXPLAIN on any captured query. No application code changes needed — just change the port.


Comments

qxxxtoday at 8:19 AM

Just tried it out. Works fine. Love it! I tried it with a wordpress site. It is showing hundreds of sql queries in one request (thats probably why that wordpress site is so slow lol)

What I would love to see here is:

- some kind of sorting: eg. by excecution time or order. So I can see the slowest queries.

- search/filter feature.

- faster scrolling with pgup/pgdown keys.

- maybe how often the same query was executed. I could check the code and maybe optimize the queries.

burembatoday at 6:25 AM

This is very neat! IMO inspecting the queries the agents run on the database is a better approach to understand how the code works, even more than reviewing the code.

I just tried and it works smoothly. For those who doesn't want to plug in the agents to their database directly, I built a similar tool https://dbfor.dev for the exact purpose, it just embeds PGLite and implements PG wire protocol to spin up quick PG databases with a traffic viewer included.

debarshritoday at 6:52 AM

We do something similar in adaptive [1].

What you can also do is add frontend and backend user to the proxy and then agents won't ever get the actual db user and password. You can make it throwaway too as well as just in time if you want.

Traditionally it was database activity monitoring which kind of fell out of fashion, but i think it is going to be back with advent of agents.

[1] https://adaptive.live

camel_gophertoday at 8:02 AM

Why do you need a proxy? Pull the queries off the network. You’re adding latency to every query!

https://github.com/circonus-labs/wirelatency

show 1 reply
altmanaltmantoday at 7:24 AM

Looks really cool, will try it out soon

stephenrtoday at 7:26 AM

Can you explain how this is a better option than just enabling the general log for MySQL as needed?

show 2 replies
Spixel_today at 7:48 AM

Maybe consider renaming this since pgTAP [0] exists and has nothing to do with this.

[0]: https://pgtap.org/

nwellinghofftoday at 5:19 AM

Nice. I like how you made it an easy to drop in proxy. Will definitely use this when debugging issues!

CodeWriter23today at 7:06 AM

Really been wanting something like this. Thanks!

ranger_dangertoday at 8:51 AM

I prefer to use eBPF; no additional software, proxy or configuration needed.

https://eunomia.dev/tutorials/40-mysql/

sneaktoday at 7:58 AM

Was AI used to build this? It looks a lot like the kind of scratch-an-itch projects I have been grinding out with AI lately, in size, timeline, code, and function. If not, you are a very very productive programmer.

If so, would you mind sharing which model(s) you used and what tooling?

jauntywundrkindtoday at 5:52 AM

That's some sick observability, nice.

mergisitoday at 7:50 AM

[dead]

devcraft_aitoday at 8:30 AM

[dead]

MUSTANG303today at 6:40 AM

[dead]