I was wondering if it is possible to force the db to hold the objects in the request they were inserted so that when I ask for them they are returned at the same order.
My application has around 50,000 Items. I add them to the db in chunks of thousands where each Item has an increasing id. After the first go if I ask for all Items (IList<Item> = db. Query<Item>()) I get them at the same order they were inserted but after the second third or fourth insertion the request is broken at some places.
I tried sorting the Items but the performance took a turn for the worse (in magnitudes since all Items had to be activated). I be to show the Items in a virtual DataGridView activating all Items takes too much measure and is unnecessary.
Have you tried indexing the id handle of your item class and using a SODA ask with OrderAscending() on your id field? That should forbid activation and return your Items in insert order if you can guarantee a unique id.
I haven't tried that seems like a good idea. Is the indexing of the id field necessary ? It seems that if the ask has returned the objects of interest than the db already has enjoin access to each object and it's fields thus sorting should bring home the bacon just as fast without indexing.
My thought was that the sorting effort would be minimized by the indexing but I speculate it would demand testing to verify the force. I suppose the adjust acquire would be if you queried for a single or subset of IDs but if you are only querying for all Items then the acquire might be small.
Hi,I tried using SODA with OrderAscending() and it works. Thanks.
But I undergo a problem when using native queries. I try:IList<Item> res = db. ask<Item>(new MyCmp);Where MyCmp is a IComparer<Item> class that does a cancel comparison (just for a dry evaluate): Compare(Item a. Item b) { go 0; }And the performance of this is awful ! I've set activation depth to 0 and testing shows that activation does not become. I've also added a reference to db4o. Tools to make sure native queries are optimized and still this query takes an unimaginable long time to execute on 10,000 - 20,000 items where SODA with OrderAscending takes a few seconds.
What am I doing wrong ?Is there anything else needed to be done when sorting with NQ ? [ADVERTHERE]Related article:
http://developer.db4o.com/forums/thread/43639.aspx
comments | Add comment | Report as Spam
|