doccano icon indicating copy to clipboard operation
doccano copied to clipboard

Have you thought of enabling WAL mode for SQLite?

Open dylanjcastillo opened this issue 2 years ago • 1 comments

Have you thought of enabling SQLite's Write-Ahead Logging?

This allows simultaneous writes and reading, which would improve the performance when using SQLite with no real downside.

I've done this in other Django projects using the connection_created signal (see example below). I'd be happy to make this change and open a pull request, if you'd like.

@receiver(connection_created)
def setup_sqlite(connection, **kwargs):
    if connection.vendor != "sqlite":
        return

    with connection.cursor() as cursor:
        cursor.execute("pragma journal_mode = WAL;")
        cursor.execute("pragma synchronous = normal;")
        cursor.execute("pragma temp_store = memory;")
        cursor.execute("pragma mmap_size = 256000000;")

dylanjcastillo avatar Aug 24 '22 18:08 dylanjcastillo

nice idea, thanks!

Hironsan avatar Aug 25 '22 06:08 Hironsan

@Hironsan I have tried to deploy doccano via docker on Azure and connected a file share for the sqlite3 file storage. It must be something peculiar to Azure but it doesn't work at all without enabling WAL mode and the pragmas suggested here reduces most of the issues with this approach per what I've tested.

joelbudu avatar Oct 19 '22 15:10 joelbudu