MCPcopy Create free account
hub / github.com/PostHog/duckgres / normalizeQueryHash

Function normalizeQueryHash

server/querylog.go:569–593  ·  view source on GitHub ↗

normalizeQueryHash computes a FNV-1a hash of a query after collapsing whitespace and replacing literals with placeholders. This groups queries that differ only in parameter values.

(query string)

Source from the content-addressed store, hash-verified

567 WrittenRows: writtenRows,
568 ExceptionCode: errCode,
569 Exception: errMsg,
570 UserName: c.username,
571 OrgID: c.orgID,
572 CurrentDatabase: c.database,
573 ClientAddress: clientAddr,
574 ClientPort: clientPort,
575 ApplicationName: c.applicationName,
576 PID: c.pid,
577 WorkerID: c.workerID,
578 IsTranspiled: isTranspiled,
579 Protocol: protocol,
580 TraceID: observe.TraceIDFromContext(c.ctx),
581 SpanID: observe.SpanIDFromContext(c.ctx),
582 PostgresScanMs: pgScanMs,
583 CPUTimeSeconds: profilingSummary.CPUTimeSeconds,
584 PeakBufferMemoryBytes: profilingSummary.PeakBufferMemoryBytes,
585 QueryMetadata: encodedMeta,
586 AccessKinds: accessKinds,
587 MetadataComplete: metaComplete,
588 WorkerTier: c.currentWorkerTier(),
589 })
590}
591
592// splitHostPort splits a host:port pair.
593func splitHostPort(addr string) (string, string, error) {
594 return net.SplitHostPort(addr)
595}
596

Callers 2

logQueryMethod · 0.85
TestNormalizeQueryHashFunction · 0.85

Calls 2

StringMethod · 0.45
WriteMethod · 0.45

Tested by 1

TestNormalizeQueryHashFunction · 0.68