mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-12-23 00:45:52 -05:00
improvement: more granular perf logging for SQL queries
This commit is contained in:
parent
2f63417646
commit
9c1b21cbfe
10
src/db.rs
10
src/db.rs
|
@ -513,11 +513,19 @@ pub async fn db_query(
|
|||
let start = Instant::now();
|
||||
// generate SQL query
|
||||
let (q, p) = query_from_sub(&sub);
|
||||
debug!("SQL generated in {:?}", start.elapsed());
|
||||
let start = Instant::now();
|
||||
// execute the query. Don't cache, since queries vary so much.
|
||||
let mut stmt = conn.prepare(&q)?;
|
||||
let mut event_rows = stmt.query(rusqlite::params_from_iter(p))?;
|
||||
let mut first_result = true;
|
||||
while let Some(row) = event_rows.next()? {
|
||||
// check if this is still active (we could do this every N rows)
|
||||
if first_result {
|
||||
debug!("time to first result: {:?}", start.elapsed());
|
||||
first_result = false;
|
||||
}
|
||||
// check if this is still active
|
||||
// TODO: check every N rows
|
||||
if abandon_query_rx.try_recv().is_ok() {
|
||||
debug!("query aborted");
|
||||
return Ok(());
|
||||
|
|
Loading…
Reference in New Issue
Block a user