I need to fill a database with millions of records, and my current routine for that looks something like:
For I = 1 to 10000000
INSERT INTO TABLE1 ...
INSERT INTO TABLE2 ...
INSERT INTO TABLE3 ...
Next
I noticed that the records also appear in this order (alternating开发者_如何转开发) in the database file on disk. Would there be a performance improvement when I do this:
For I = 1 to 10000000
INSERT INTO TABLE1 ...
Next
For I = 1 to 10000000
INSERT INTO TABLE2 ...
Next
For I = 1 to 10000000
INSERT INTO TABLE3 ...
Next
Or doesn't it matter for query-performance how the data is structured on disk?
By using the second approach you will gain some tiny little performance, if you care that much to take it in consideration. But it depends on the physical disk, how much is the fragmentation.
I think you should focus on optimizing your database and queries.
精彩评论