SQLite Forum

Slow select operation after many times of insert different Table
Login
My guess as to what's going on:

For db1 you're shuffling all the pages of the three tables together as you build the file. As you evenly deal out the inserts between then, then as the db file grows it's basically going to be laid out as page for Test1, page for Test2, page for Test3, page for Test1, page for Test2, page for Test3, etc... So when you read  everything from Test1, you need to read every third page over the entire length of the file.

When you do the inserts into db2 and db3, you're keeping each table together. So as the db file grows you have a big swath of pages all for Test1, then a big swath of pages all for Test2, then a big swath of pages all for Test3. So when you read all of Test1, you're basically reading all continuous pages in the first third of the file.

That's going to make a difference, especially if you have a spinning hard disk for the file. Whether that's the difference you're seeing I'll let the more knowledgeable folks reply.