본문으로 바로가기
let db = new sqlite3.Database(':memory:');

 

db명을 ":memory:"로 하면 디스크에 저장되지 않고 메모리 위에서 동작한다.

 

1700여개의 파일을 읽고 DB에 쓰는 작업시 21s -> 1s로 20배 이상 빨라졌다. RAM에 있으니 데이터 유실에 주의할 것.

 

 

 

SQLite In-Memory Databases 레퍼런스 : https://www.sqlite.org/inmemorydb.html

 

In-Memory Databases

An SQLite database is normally stored in a single ordinary disk file. However, in certain circumstances, the database might be stored in memory. The most common way to force an SQLite database to exist purely in memory is to open the database using the spe

www.sqlite.org

node-sqlite3 API 레퍼런스 : https://github.com/mapbox/node-sqlite3/wiki/API

 

mapbox/node-sqlite3

Asynchronous, non-blocking SQLite3 bindings for Node.js - mapbox/node-sqlite3

github.com