This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
It looks like the KeyTable id generation method has very strong performance impact. I attach an example. Please do the following:
Please let me know why the KeyTable id generation is so slow and how to avoid this problem. |
|
|
By default, KeyTable gets IDs in blocks of 10. You are adding 1000 entities to the database, which means KeyTable needs to hit the database 100 times just to get IDs (well, 200 times actually, as each request involves a SELECT and an UPDATE). If you change the LightSpeedContext.IdentityBlockSize to 1000, then LightSpeed can get all the IDs it needs in one database request. In my test this dropped the allocation time from 6 seconds down to 0.2 seconds. That said, even doing 100 requests for blocks of 10 should be much faster than 6 seconds. It seems this occurs because KeyTable has to do its SELECT and UPDATE in a transaction, and this slows SQLite down. If you put a TransactionScope around your Add loop (so that the bulk adds are all occurring within the same TransactionScope), then this overhead is not incurred and I see a speed of around 0.3 seconds (with the default IdentityBlockSize of 10). |
|
|
It works great! Thank you - you're ORM masters :-) |
|