pg icon indicating copy to clipboard operation
pg copied to clipboard

Add support for sqlcommenter

Open hypnoglow opened this issue 3 years ago • 2 comments

Summary

It would be great if go-pg could support sqlcommenter to gain insights about query performance of particular client apps or components.

Reference implementations for other languages\ORMs are available in this repo: https://github.com/google/sqlcommenter/

Possible Implementation

For simplest integration go-pg could allow adding arbitrary comments to queries. This way clients could have full control of the syntax and desired tags. This could be even used by other tools, not only sqlcommenter.

Or go-pg could have builtin coverage of sqlcommenter features, with tags like framework, route etc like in reference implementations.

hypnoglow avatar Feb 06 '21 00:02 hypnoglow

I am not saying we should not support sqlcommenter, but we have tracing support that achieves the same - https://pg.uptrace.dev/tracing/

vmihailenco avatar Feb 06 '21 15:02 vmihailenco

but we have tracing support that achieves the same

Not exactly. This is more like client-side tracing. Among others, it includes network costs. When we see that a query took 200ms it might mean that there was a network latency of 100ms and it took Postgres 100ms to execute query. Without a question this is still useful, but with sqlcommenter tooling we can measure pure database performance.

hypnoglow avatar Feb 07 '21 15:02 hypnoglow