For all those who are not aware of the topic questioned, let me tell you that what is WAL, it is Write.Ahead Logging. What does it mean? basically, the concept is to improve the write operation on DB.
We all don't know how third party lib works, how efficient they are? until we get deep into the third party we don't know it's efficiency. react-native-sqlite-storage
is a whizzo work so nothing to bother about however we have to implement few things feature on our side to make things look better.
PRAGMA journal_mode=WAL is a query to add new data to the write-ahead logging file. I mean whenever we write new data in DB then what happens is that it copies the previously written data to the rollback files and the new data is written directly to the DB file Thus, it is not a good practice when large amount of data is written in the DB files hence, results in two disk write for every DB change.
WAL can make you live peacefully by not writing new data to the DB directly instead of it writes the new data to the logging file Hence, this results in single disk write.
Now let's how it works:
In the below code snippet when you open the DB for the first time this function will be invoked and you can populate your DB by executing another query in this function after mode query.
populateDatabase(db) {
const selectMode = 'PRAGMA journal_mode=WAL;'
db.executeSql(selectMode, [],
() => {
console.log('running query...')
},
(error) => {
console.log('error implementing', error)
})
}
Everything seems cool. Please don't hesitate to ask questions.
Cheers :)
EDIT 1:
There is a performance issue while using WAL, Performance for reads
can suffer from a large WAL file because data has to be searched in
two places.