mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 00:59:07 -05:00
fix: use accurate timer for slow queries, and use 250ms as cutoff
This commit is contained in:
parent
6d57adef73
commit
c8e8b71b91
|
@ -347,7 +347,7 @@ impl NostrRepo for SqliteRepo {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let mut row_count: usize = 0;
|
let mut row_count: usize = 0;
|
||||||
// cutoff for displaying slow queries
|
// cutoff for displaying slow queries
|
||||||
let slow_cutoff = Duration::from_millis(1000);
|
let slow_cutoff = Duration::from_millis(250);
|
||||||
let mut filter_count = 0;
|
let mut filter_count = 0;
|
||||||
for filter in sub.filters.iter() {
|
for filter in sub.filters.iter() {
|
||||||
let filter_start = Instant::now();
|
let filter_start = Instant::now();
|
||||||
|
@ -448,10 +448,10 @@ impl NostrRepo for SqliteRepo {
|
||||||
warn!("Could not get a database connection for querying");
|
warn!("Could not get a database connection for querying");
|
||||||
}
|
}
|
||||||
// if the filter took more than 1 second of db_time, print out the JSON.
|
// if the filter took more than 1 second of db_time, print out the JSON.
|
||||||
if start.elapsed() > slow_cutoff && client_id.starts_with('0') {
|
if filter_start.elapsed() > slow_cutoff && client_id.starts_with('0') {
|
||||||
debug!(
|
debug!(
|
||||||
"query filter req (slow): {} (cid: {}, sub: {:?})",
|
"query filter req (slow): {} (cid: {}, sub: {:?}, filter: {})",
|
||||||
serde_json::to_string(&filter)?, client_id, sub.id
|
serde_json::to_string(&filter)?, client_id, sub.id, filter_count
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user