You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Dashboard Interface**: Visual dashboard for monitoring query performance metrics
14
-
-**Detailed Query Information**: Displays query details including duration, status, bindings, and more
14
+
-**Detailed Query Information**: Displays query details including duration, status, bindings, and caller traces for slow or failed queries
15
15
-**Advanced Filtering**: Filter queries by type, status, connection, and more
16
16
-**Optimization Suggestions**: Automated recommendations for improving query performance
17
17
@@ -27,6 +27,9 @@ export default {
27
27
// Enable or disable query logging
28
28
enabled: true,
29
29
30
+
// Also capture caller stacks for successful fast queries
31
+
captureAllTraces: false,
32
+
30
33
// Threshold in milliseconds to mark a query as slow
31
34
slowThreshold: 100,
32
35
@@ -56,6 +59,7 @@ You can also configure query monitoring using environment variables:
56
59
57
60
```
58
61
DB_QUERY_LOGGING_ENABLED=true
62
+
DB_QUERY_LOGGING_CAPTURE_ALL_TRACES=false
59
63
DB_QUERY_LOGGING_SLOW_THRESHOLD=100
60
64
DB_QUERY_LOGGING_RETENTION_DAYS=7
61
65
DB_QUERY_LOGGING_PRUNE_FREQUENCY=24
@@ -103,7 +107,7 @@ The detail view provides comprehensive information about a specific query:
103
107
- Full query text and normalized version
104
108
- Execution metrics and duration
105
109
- Bindings and parameters
106
-
- Stack trace and caller information
110
+
- Stack trace and caller information for slow or failed queries
107
111
- Index usage information
108
112
- EXPLAIN plan data
109
113
- Optimization suggestions
@@ -135,11 +139,11 @@ Queries are stored in the `query_logs` table with the following structure:
135
139
| error | text | Error message if failed |
136
140
| executed_at | timestamp | When the query was executed |
137
141
| bindings | text | JSON array of query parameters |
138
-
| trace | text | Stack trace showing where query was called|
139
-
| model | text | Model that executed the query |
140
-
| method | text | Method that executed the query |
141
-
| file | text | File path where query originated |
142
-
| line | integer | Line number where query originated |
142
+
| trace | text | Stack trace for a slow or failed query|
143
+
| model | text | Model that executed a slow or failed query |
144
+
| method | text | Method that executed a slow or failed query |
145
+
| file | text | File path where a slow or failed query originated |
146
+
| line | integer | Line number where a slow or failed query originated |
143
147
| memory_usage | numeric | Memory used during execution |
144
148
| rows_affected | integer | Number of rows affected |
145
149
| transaction_id | text | Related transaction identifier |
@@ -164,7 +168,9 @@ The system includes a scheduled job (`PruneQueryLogsJob`) that automatically rem
164
168
165
169
4.**Database Impact**: Be aware that query logging itself adds some overhead. Monitor the performance impact and adjust settings accordingly.
166
170
167
-
5.**Security**: Query logs may contain sensitive information in bindings. Ensure that access to the query dashboard is properly secured.
171
+
5.**Caller Traces**: Slow and failed queries always include caller traces. Enable `captureAllTraces` only when fast-query call sites are worth the additional CPU and storage cost.
172
+
173
+
6.**Security**: Query logs may contain sensitive information in bindings. Ensure that access to the query dashboard is properly secured.
constrecords=awaitdb.unsafe('SELECT query, status, affected_tables, tags FROM query_logs WHERE query IN (?, ?)',[ordinarySql,analyzedSql]).execute()
163
+
constrecords=awaitdb.unsafe('SELECT query, status, affected_tables, tags, trace FROM query_logs WHERE query IN (?, ?)',[ordinarySql,analyzedSql]).execute()
0 commit comments