Compare commits
2 commits
master
...
sqlite-per
| Author | SHA1 | Date | |
|---|---|---|---|
| f1a3c0a8cf | |||
| 40814a7efb |
3 changed files with 325 additions and 376 deletions
597
Cargo.lock
generated
597
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
64
Cargo.toml
64
Cargo.toml
|
|
@ -7,43 +7,49 @@ version = "0.8.3"
|
|||
edition = "2021"
|
||||
|
||||
[workspace.dependencies]
|
||||
anyhow = "1.0.86"
|
||||
async-trait = "0.1.80"
|
||||
clap = { version = "4.5.4", features = ["derive", "deprecated"] }
|
||||
anyhow = "1.0.96"
|
||||
async-trait = "0.1.86"
|
||||
clap = { version = "4.5.30", features = ["derive", "deprecated"] }
|
||||
cookie = "0.18.1"
|
||||
crossterm = "0.27.0"
|
||||
directories = "5.0.1"
|
||||
crossterm = "0.28.1"
|
||||
directories = "6.0.0"
|
||||
edit = "0.1.5"
|
||||
jiff = "0.2.1"
|
||||
linkify = "0.10.0"
|
||||
log = { version = "0.4.21", features = ["std"] }
|
||||
once_cell = "1.19.0"
|
||||
open = "5.1.3"
|
||||
parking_lot = "0.12.2"
|
||||
proc-macro2 = "1.0.83"
|
||||
quote = "1.0.36"
|
||||
rusqlite = { version = "0.31.0", features = ["bundled", "time"] }
|
||||
rustls = "0.23.19"
|
||||
serde = { version = "1.0.202", features = ["derive"] }
|
||||
log = { version = "0.4.25", features = ["std"] }
|
||||
once_cell = "1.20.2"
|
||||
open = "5.3.2"
|
||||
parking_lot = "0.12.3"
|
||||
proc-macro2 = "1.0.93"
|
||||
quote = "1.0.38"
|
||||
rusqlite = { version = "0.31.0", features = [
|
||||
# "bundled",
|
||||
"time",
|
||||
] }
|
||||
rustls = "0.23.23"
|
||||
serde = { version = "1.0.218", features = ["derive"] }
|
||||
serde_either = "0.2.1"
|
||||
serde_json = "1.0.117"
|
||||
syn = "2.0.65"
|
||||
thiserror = "1.0.61"
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
toml = "0.8.13"
|
||||
unicode-width = "0.1.12"
|
||||
serde_json = "1.0.139"
|
||||
syn = "2.0.98"
|
||||
thiserror = "2.0.11"
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
toml = "0.8.20"
|
||||
unicode-width = "0.2.0"
|
||||
|
||||
[workspace.dependencies.euphoxide]
|
||||
git = "https://github.com/Garmelon/euphoxide.git"
|
||||
path = "../euphoxide"
|
||||
# git = "https://github.com/Garmelon/euphoxide.git"
|
||||
features = ["bot"]
|
||||
|
||||
[workspace.dependencies.toss]
|
||||
git = "https://github.com/Garmelon/toss.git"
|
||||
tag = "v0.2.3"
|
||||
path = "../toss"
|
||||
# git = "https://github.com/Garmelon/toss.git"
|
||||
# tag = "v0.2.3"
|
||||
|
||||
[workspace.dependencies.vault]
|
||||
git = "https://github.com/Garmelon/vault.git"
|
||||
tag = "v0.4.0"
|
||||
path = "../vault"
|
||||
# git = "https://github.com/Garmelon/vault.git"
|
||||
# tag = "v0.5.0"
|
||||
features = ["tokio"]
|
||||
|
||||
[workspace.lints]
|
||||
|
|
@ -71,3 +77,11 @@ clippy.use_self = "warn"
|
|||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
# For profiling
|
||||
|
||||
[profile.release]
|
||||
debug = 1
|
||||
|
||||
[rust]
|
||||
debuginfo-level = 1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use std::str::FromStr;
|
||||
use std::time::Instant;
|
||||
use std::{fmt, mem};
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
|
@ -686,12 +687,12 @@ impl Action for GetTree {
|
|||
type Error = rusqlite::Error;
|
||||
|
||||
fn run(self, conn: &mut Connection) -> Result<Self::Output, Self::Error> {
|
||||
let msgs = conn
|
||||
.prepare(
|
||||
"
|
||||
let start = Instant::now();
|
||||
|
||||
let query = "
|
||||
WITH RECURSIVE
|
||||
tree (domain, room, id) AS (
|
||||
VALUES (?, ?, ?)
|
||||
VALUES (:domain, :room, :id)
|
||||
UNION
|
||||
SELECT euph_msgs.domain, euph_msgs.room, euph_msgs.id
|
||||
FROM euph_msgs
|
||||
|
|
@ -700,14 +701,35 @@ impl Action for GetTree {
|
|||
AND tree.room = euph_msgs.room
|
||||
AND tree.id = euph_msgs.parent
|
||||
)
|
||||
SELECT id, parent, time, name, content, seen
|
||||
SELECT id, parent, time, 'name', 'content', 1
|
||||
FROM euph_msgs
|
||||
JOIN tree USING (domain, room, id)
|
||||
ORDER BY id ASC
|
||||
",
|
||||
)?
|
||||
";
|
||||
|
||||
let mut statement = conn.prepare(&format!("EXPLAIN QUERY PLAN {query}"))?;
|
||||
let mut rows = statement.query(named_params! {
|
||||
":domain": self.room.domain,
|
||||
":room": self.room.name,
|
||||
":id": WSnowflake(self.root_id.0),
|
||||
})?;
|
||||
|
||||
while let Some(row) = rows.next()? {
|
||||
let id = row.get::<_, i64>("id")?;
|
||||
let parent = row.get::<_, i64>("parent")?;
|
||||
let notused = row.get::<_, i64>("notused")?;
|
||||
let detail = row.get::<_, String>("detail")?;
|
||||
eprintln!("{parent:3} -> {id:3} (notused {notused:3}): {detail}");
|
||||
}
|
||||
|
||||
let msgs = conn
|
||||
.prepare(query)?
|
||||
.query_map(
|
||||
params![self.room.domain, self.room.name, WSnowflake(self.root_id.0)],
|
||||
named_params! {
|
||||
":domain": self.room.domain,
|
||||
":room": self.room.name,
|
||||
":id": WSnowflake(self.root_id.0),
|
||||
},
|
||||
|row| {
|
||||
Ok(SmallMessage {
|
||||
id: MessageId(row.get::<_, WSnowflake>(0)?.0),
|
||||
|
|
@ -720,6 +742,8 @@ impl Action for GetTree {
|
|||
},
|
||||
)?
|
||||
.collect::<rusqlite::Result<_>>()?;
|
||||
let end = Instant::now();
|
||||
eprintln!("{:10}", end.duration_since(start).as_micros());
|
||||
Ok(Tree::new(self.root_id, msgs))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue