ryanfowler / SwiftData

Simple and Effective SQLite Handling in Swift
MIT License
518 stars 93 forks source link

Slowness #9

Open ArifADS opened 10 years ago

ArifADS commented 10 years ago

I wonder why it takes 11 seconds to insert 250 rows with ~12 columns, or ~7 seconds a 80Kb File to String in one row.

Is there a better way to Insert/update?

ryanfowler commented 9 years ago

This seems unusual - I don't experience this slowness in my testing, Would you be able to provide the data you're trying to insert?

If you have some kind of loop that just calls SD.executeChange(...) for all 250 rows, be aware that this is open and close the database connection 250 times. If you have many inserts, I suggest to use the functions: SD.executeMultipleChanges(...) or SD.executeWithConnection(...).

In both cases, all changes will run on a single connection to the database.