SQlite3 slow writes in WAL mode

I am trying to see the insert performance of SQLite3 for a large number of inserts, I read about WAL mode, and how it is better at concurrency but I cannot follow on the concurrency part or see a speed improvement.

I have set JOURNAL_MODE=WAL, SYNCHRONOUS=NORMAL, OFF on a few runs but the database inserts in WAL mode are slower than the default JOURNAL_MODE=DELETE mode.
The benefit of WAL mode seems to be it allows multiple readers and 1 writer

Here is the code or the writer

import sqlite3
import time
import json
import pickle
import os
import random

REC_LIMIT = 100000

def getDBConn() -> sqlite3.Connection:
   conn = sqlite3.connect('test.db')
   # conn.execute('pragma journal_mode=memory')
   # conn.execute('pragma journal_mode=WAL')
   conn.execute('pragma synchronous=FULL')
   for row in conn.execute('pragma journal_mode').fetchall():
      print(row)
   for row in conn.execute('pragma synchronous').fetchall():
      print(row)
   conn.commit()
   return conn

def cleanup():
   if os.access('test.db', os.F_OK):
      os.unlink('test.db')
   time.sleep(2)

def initDB():
   with getDBConn() as conn:
      tbl_query = "CREATE TABLE IF NOT EXISTS test_table (eid INTEGER PRIMARY_KEY, username TEXT, json TEXT, pickled_json BLOB)"
      conn.execute(tbl_query)


def genusername() -> str:
   arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
   result = []
   for i in range(30):
      result.append(random.choice(arr))
   return "".join(result)

def gen_records() -> list:
   records = []
   str_dummy_payload = '''BIG JSON'''
   dummy_payload = json.loads(str_dummy_payload)
   dummy_payload = pickle.dumps(dummy_payload)
   for i in range(REC_LIMIT):
      records.append((genusername(), str_dummy_payload, pickle.dumps(dummy_payload)))
   print("Generated recordsn")
   return records

def batch_insert(records: list):
   cleanup()
   initDB()
   start = time.process_time()
   with getDBConn() as conn:
      cur = conn.cursor()
      stmt = "INSERT INTO test_table (username, json, pickled_json) VALUES (?,?,?);"
      for idx,row in enumerate(records):
         if idx % 1000 == 0:
            conn.commit()
         cur.execute(stmt, row)
      cur.close()
   print(f"nTime taken while insert in small batches {time.process_time() - start} n")

def long_write(records):
   start = time.process_time()
   with getDBConn() as conn:
      cur = conn.cursor()
      stmt = "INSERT INTO test_table (username, json, pickled_json) VALUES (?,?,?);"
      cur.execute(stmt, records[0])
      print("Begin long write....")
      time.sleep(50)
      cur.close()
   print(f"nTime taken while using single insert {time.process_time() - start} n")

def main():
   records = gen_records()
   batch_insert(records)
   long_write(records)
main()

Reader

import sqlite3
import time

conn = sqlite3.connect('test.db')
cur = conn.cursor()
stmt = "SELECT * from test_table LIMIT 10;"
for i in range(1000000000):
    cur.execute(stmt)
    for row in cur.fetchall():
        # print(row)
        pass
cur.close()
conn.close()
print("Read Completed!")

Say I create multiple readers and then call the writer I never come across the database-locked issue, similarly when the writer is going I call the readers it works fine no database-locked issue.

If I do insert/update from 2 processes, I do hit the database locked issue as expected.

The only scenario(multiple readers 1 writer) when I see a database-locked is
if I do

BEGIN TRANSACTION EXCLUSIVE

when doing inserts or updates

WAL is useful when I use EXCLUSIVE
Does it mean my reads are wrong/incorrect if I don’t use ‘exclusive’ during writes/updates?

If I don’t use exclusive I don’t see any benefit of WAL mode, the inserts are much slower as the number of records increases.
What is the right way to insert/update data in SQLite3?
How unsafe is it to set SYNCHRONOUS=OFF, from the docs it seems like unless the OS crashes or a power failure the database should be fine.

OperatingSystem: OpenSuse Leap 15.5
Python version: 3.6.15

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật