-
Notifications
You must be signed in to change notification settings - Fork 5
feat: update database config #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,14 +27,23 @@ use tokio::sync::{Mutex, Semaphore}; | |
| const BUSY_TIMEOUT_SECS: u64 = 5; | ||
|
|
||
| /// The maximum number of connections in the database connection pool. | ||
| const MAX_CONNECTIONS: u32 = 32; | ||
| const MAX_CONNECTIONS: u32 = 6; | ||
|
|
||
| /// The minimum number of connections in the database connection pool. | ||
| const MIN_CONNECTIONS: u32 = 5; | ||
| const MIN_CONNECTIONS: u32 = 2; | ||
|
|
||
| /// The timeout for acquiring a connection from the pool. | ||
| const ACQUIRE_TIMEOUT_SECS: u64 = 5; | ||
|
|
||
| /// The cache size in KB | ||
| const CACHE_SIZE_KB: &str = "-131072"; // 128 MB | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a typo?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean the variable name?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the dash in front of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahhh no, positive numbers specify number of pages, negative numbers specify the size in KB:
|
||
|
|
||
| /// The mmap size in bytes | ||
| const MMAP_SIZE_BYTES: &str = "536870912"; // 512 MB | ||
|
|
||
| /// The wal auto checkpoint size in pages | ||
| const WAL_AUTO_CHECKPOINT_PAGES: &str = "50000"; // 200 MB (with default page size of 4 KB) | ||
|
|
||
| /// A wrapper around `DatabaseInner` which provides retry features. | ||
| #[derive(Debug)] | ||
| pub struct Database { | ||
|
|
@@ -595,7 +604,11 @@ impl DatabaseInner { | |
| .journal_mode(sea_orm::sqlx::sqlite::SqliteJournalMode::Wal) | ||
| .busy_timeout(Duration::from_secs(busy_timeout_secs)) | ||
| .foreign_keys(true) | ||
| .synchronous(sea_orm::sqlx::sqlite::SqliteSynchronous::Normal); | ||
| .synchronous(sea_orm::sqlx::sqlite::SqliteSynchronous::Normal) | ||
| .pragma("cache_size", CACHE_SIZE_KB) | ||
| .pragma("mmap_size", MMAP_SIZE_BYTES) | ||
| .pragma("wal_autocheckpoint", WAL_AUTO_CHECKPOINT_PAGES) | ||
| .pragma("temp_store", "MEMORY"); | ||
|
|
||
| let sqlx_pool = SqlitePoolOptions::new() | ||
| .max_connections(max_connections) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,5 +78,7 @@ main() { | |
| log_info "Next queue index: $next_queue_index " | ||
| done | ||
|
|
||
| echo "Done" | ||
| log_info "Done" | ||
| } | ||
|
|
||
| main "$@" | ||
Uh oh!
There was an error while loading. Please reload this page.