Skip to content

Source Code Mapping

Query Doctor can link every query captured by pg_stat_statements back to the application code that produced it — the source file, line number, HTTP route, and request method. This is powered by SQLCommenter tags that your ORM appends as structured SQL comments.

An SQLCommenter-enabled ORM wraps each query in a comment containing key-value metadata:

/* file='src%2Fusers%2Fservice.ts%3A42%3A5',route='%2Fapi%2Fusers',method='GET',db_driver='drizzle' */
SELECT id, name FROM users WHERE active = true;

When Query Doctor reads pg_stat_statements, its analyzer extracts these tags and displays them all alongside the query in the Live Queries detail view. Every tag is shown as a key-value pair, but the file tag gets special treatment — when present, Query Doctor renders it as a clickable link that opens the exact file and line in your IDE (see Configuring your IDE below).

TagDescription
fileSource file, line, and column (path:line:column)
routeHTTP route that triggered the query
methodHTTP request method (GET, POST, etc.)
db_driverORM / driver identifier
Custom tagsAny arbitrary key-value pairs you attach

Trace context (OpenTelemetry span and trace IDs) is included automatically when a tracer is active.

Install a tracking integration for your database driver or ORM:

Once the integration is in place, new queries that hit the database will carry the comment tags. Existing entries in pg_stat_statements won’t have them.

When a query has a file tag, the path is rendered as a clickable link. To have it open directly in your editor, configure the IDE selector:

  1. Open the Live Queries page.
  2. Click the settings icon in the toolbar.
  3. Choose your Preferred IDE.
  4. For JetBrains IDEs, also set the Project path (the local root of your project) so that relative paths resolve correctly.
  • Cursor
  • VS Code

Uses the vscode://file/path:line:column protocol.