HNHacker News
TopNewBestAskShowJobs

slaily

119 karma · joined November 7, 2023

Software Maker.
submissionscomments
slaily··on SQLite async connection pool for high-performance
When your program does heavy concurrent writing and opens/closes connections for each write, most of them will fail with SQLITE_BUSY or SQLITE_LOCKED errors.

This situation can be managed with a pool of small (5 connections or less) to prevent spawning too many connections. This will reduce racing between them and allow write operations to succeed.

slaily··on SQLite async connection pool for high-performance
If you’re building Python async apps (FastAPI, background jobs, etc.) with SQLite, you’ll eventually hit two issues

- Opening/closing connections is fast, but not free—overhead adds up under load

- SQLite writes are globally locked

aiosqlitepool is a tiny library that adds connection pooling for any asyncio SQLite driver (like aiosqlite):

- It avoids repeated database connection setup (syscalls, memory allocation) and teardown (syscalls, deallocation) by reusing long-lived connections

- Long-lived connections keep SQLite's in-memory page cache "hot." This serves frequently requested data directly from memory, speeding up repetitive queries and reducing I/O operations

- Allows your application to process significantly more database queries per second under heavy load

Enjoy!

slaily··on Show HN: Free deep work app with no ads, no paywalls, and no tracking
Here's the routine I've developed:

1. Pre-work ritual: 5 minutes of breathing exercises to clear my mind.

2. Environment setup: Focus music (playlist), all notifications off.

3. Session structure:

    - 90 minute deep work blocks (using the "Deep Dive" timer)

    - 15 minute breaks between sessions
4. During sessions:

    - Single task focus (e.g., one feature or bug)

    - Handwritten notes for ideas/distractions
5. Post-session: Quick review and plan for the next block