I wonder if defining a virtual table ( https://www.sqlite.org/vtab.html ) and just doing INSERT INTO t (...) SELECT ... from virtual_table would be any faster.
Inserting a billion rows in SQLite under a minute
161–164 of 164 posts
Re: Inserting a billion rows in SQLite under a minute
#162How long does it take when using the native CSV import features? https://www.sqlite.org/csv.html
I just shat out a CSV file and then imported it. It was much quicker! (like 1000x faster)
This article has some useful notes for me now to try the next time I play with my pet projects. :)
Re: Inserting a billion rows in SQLite under a minute
#163Hey all, author here. I didn't expect this to reach front page of HN. I came here to submit and it was here already! I am looking for more ideas to experiment. Here's one idea which someone from another forum gave me: exploring recursive queries and using SQLite random methods to do the insertions. Another crazy idea is to learn about SQLite file format and just write the pages to disk.
Why don't you create in-memory database (see SQLITE_OPEN_MEMORY, or ":memory:", or sqlite3_vfs_register) and copy result to a real file?
> The machine I am using is MacBook Pro, 2019 (2.4 GHz Quad Core i5, 8GB, 256GB SSD, Big Sur 11.1)
Given the target schema, 100M rows with only 8GB RAM risks hitting swap hard.