XRAY: How to enable DB query logging

XRAY: How to enable DB query logging

AuthorFullName__c
Matthew Wang
articleNumber
000005260
ft:sourceType
Salesforce
FirstPublishedDate
2022-05-03T08:27:25Z
lastModifiedDate
2022-05-03
VersionNumber
3

In the situation where you want to view what DB queries Xray is sending to the database, along with the response time, you can enable TRACE level logging for the various microservices. Note that this logging is very verbose, and should only be enabled temporarily as needed. 

You may want to enable this kind of query logging to debug performance issues. For example, you may notice that during indexing a certain package, DB CPU usage increases drastically and indexing hangs, but you don’t know what is causing the behavior. Enabling query logging may show that a query(ies) takes a very long time, which points you in the right direction on what to look into next.

An example of the query logging is:

2022-05-02T20:13:54.377Z [jfxan] [TRACE] [89be12fea2f6635f] [sql:787                       ] [main                ] DB START TxNamedExecContext: 
UPDATE high_availability 
SET last_heartbeat = :last_heartbeat 
WHERE node_id = :node_id and ms_type = :ms_type and last_heartbeat > :heartbeat_limit
2022-05-02T20:13:54.378Z [jfxan] [TRACE] [89be12fea2f6635f] [sql:791                       ] [main                ] DB END TxNamedExecContext: 
UPDATE high_availability 
SET last_heartbeat = :last_heartbeat 
WHERE node_id = :node_id and ms_type = :ms_type and last_heartbeat > :heartbeat_limit  - took 1.675202ms