nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

commit 9c1b21cbfe4f3d089ea36a0164b12de07c727a50
parent 2f63417646ad20ee5a499974f79083062b295d8a
Author: Greg Heartsfield <scsibug@imap.cc>
Date:   Mon, 21 Feb 2022 09:03:05 -0600

improvement: more granular perf logging for SQL queries

Diffstat:
Msrc/db.rs | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/db.rs b/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(());