-Removed default value for max_days option
+Adding note about query performance
This commit is contained in:
parent
f1a0771855
commit
dd61d7e6dd
@ -11,7 +11,7 @@ use clap::{App, Arg};
|
|||||||
|
|
||||||
|
|
||||||
const MAX_DAYS_HELP: &'static str = "Purge messages older than <D> days old
|
const MAX_DAYS_HELP: &'static str = "Purge messages older than <D> days old
|
||||||
If the value is 0 (default) then messages are not deleted by their age
|
If the value is 0 then messages are not deleted by their age
|
||||||
";
|
";
|
||||||
|
|
||||||
const MSG_LIMIT_HELP: &'static str = "Sets the max number of messages per channel.
|
const MSG_LIMIT_HELP: &'static str = "Sets the max number of messages per channel.
|
||||||
@ -42,9 +42,19 @@ async fn remove_old(pool: &Pool, age_limit: i64) -> Result<(), mysql_async::Erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async fn remove_maxed(pool: &Pool, max_msg: u64) -> Result<(), mysql_async::Error> {
|
async fn remove_maxed(pool: &Pool, max_msg: u64) -> Result<(), mysql_async::Error> {
|
||||||
// grab each channel id
|
|
||||||
// remove max by group
|
// For N channels we're going to do n+1 queries making this really expensive
|
||||||
// ?
|
// TODO: reduce this to a single query for reasons below: tags[network, sql, slow]
|
||||||
|
/*
|
||||||
|
* Multiple network hits blow(moreso if the the db is located away from the
|
||||||
|
* main server binary but i digress.
|
||||||
|
* The first hit is no the expensive part if I'm being honest,
|
||||||
|
* It's everything after that leverages the channel id's as the messages
|
||||||
|
* table is likely to be filled with a ton of shit.
|
||||||
|
*
|
||||||
|
* The trick is going to be in some really nasty group by/limit thing but
|
||||||
|
* frankly this works for now so into the backlog it goes
|
||||||
|
*/
|
||||||
let mut conn = pool.get_conn().await?;
|
let mut conn = pool.get_conn().await?;
|
||||||
let channel_ids: Vec<u64> = conn.exec_map(
|
let channel_ids: Vec<u64> = conn.exec_map(
|
||||||
"SELECT id FROM channels", (),
|
"SELECT id FROM channels", (),
|
||||||
@ -81,8 +91,7 @@ async fn main() -> Result<(), String>{
|
|||||||
.long("max-days")
|
.long("max-days")
|
||||||
.value_name("D")
|
.value_name("D")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.long_help(MAX_DAYS_HELP)
|
.long_help(MAX_DAYS_HELP))
|
||||||
.default_value("0"))
|
|
||||||
.arg(Arg::with_name("config_file")
|
.arg(Arg::with_name("config_file")
|
||||||
.short("f")
|
.short("f")
|
||||||
.long("file")
|
.long("file")
|
||||||
|
Loading…
Reference in New Issue
Block a user