Query time and database optimization

This commit is contained in:
micialware committed 2026-09-09 10:19:44 +03:00
1 parent 2e04450c76
commit 294f0e8b98
2 files changed
+18

No files matched your search

+5
View File
@@ -11,6 +11,8 @@ use rusqlite::Connection;
use std::marker::PhantomData;
use std::ops::{Deref, Index, IndexMut};
use std::sync::Arc;
use std::time::Instant;
use log::debug;
pub trait Repository<T, D>
where
@@ -158,6 +160,7 @@ impl<T: EntityData + Clone + Send + Sync, R: Repository<T, D>, D: DbLayer<T>> Qu
where
T: Send + Sync,
{
let time = Instant::now();
self.cache.clear();
if self.parallel {
self.cache = data_repository
@@ -186,6 +189,8 @@ impl<T: EntityData + Clone + Send + Sync, R: Repository<T, D>, D: DbLayer<T>> Qu
.map(|(i, entity)| EntityHandle::new(entity.id(), i, false))
.collect::<Vec<_>>(),
);
debug!("Query for {} elements (filtered {}) takes {:?}", self.len(), self.cache.len(), time.elapsed());
}
pub fn handles(&self) -> impl Iterator<Item = EntityHandle<T>> {