Skip to content

Sqlite import sql script is very slow #18854

Open
@rcdevice

Description

@rcdevice

Feature Description

When I use cmd [ sqlite3 gitea.db < gitea-db.sql ] to restore the Sqlite database from gitea-db.sql , It takes about 5-6 minutes, unbearably slow, and the data that I recovered was only a few hundred records .

Here's my solution,add two command sets at the beginning and end of the gitea-db.sql file:

PRAGMA journal_mode = MEMORY;
PRAGMA synchronous = OFF;
PRAGMA foreign_keys = OFF;
PRAGMA ignore_check_constraints = OFF;
PRAGMA auto_vacuum = NONE;
PRAGMA secure_delete = OFF;
BEGIN TRANSACTION;

<gitea-db.sql CONTENT>

COMMIT;
PRAGMA ignore_check_constraints = ON;
PRAGMA foreign_keys = ON;
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;


After the above modification, run same again, less than 1 second, very fast.

I think install Gitea with SQLite very slow to initialize is the same reason.

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/workaroundit is or has a workaroundtype/docsThis PR mainly updates/creates documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions