Refresh Collection Efficiently?

Posts   
 
    
holife
User
Posts: 3
Joined: 26-Jan-2010
# Posted on: 29-Jan-2010 10:24:25   

Hi, is it possible to refresh an entity collection efficiently? for example : 1. i load all objects into an entity collection when i open a form. 2. then when i click refresh button, i want only changed, added, removed objects from databse add to the collection (already loaded objects should not re-load again for performance reason).

i see developer express XPO support this things...smile

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 29-Jan-2010 10:30:59   

For new entities, you can always fetch from the database those entities with an ID greater than the max Id you have in the collection. That's if you are using a sequential ID, or if you have a CreatedOn Date field.

For updated objects you should have something like timestamp or LastModified Date, and then you can fetch entities where LastModified is greate than the maximum you have in the collection.

But anyway how many entities do you have on your initial collection. As you should always fetch few entities in a collection, so that a complete refresh (re-fetch) would be reasonable.

holife
User
Posts: 3
Joined: 26-Jan-2010
# Posted on: 29-Jan-2010 10:56:13   

Walaa wrote:

For new entities, you can always fetch from the database those entities with an ID greater than the max Id you have in the collection. That's if you are using a sequential ID, or if you have a CreatedOn Date field.

  • I got it...good idea smile

Walaa wrote:

For updated objects you should have something like timestamp or LastModified Date, and then you can fetch entities where LastModified is greate than the maximum you have in the collection.

  • this too smile but what about deleted objects? have any idea?

Walaa wrote:

But anyway how many entities do you have on your initial collection. As you should always fetch few entities in a collection, so that a complete refresh (re-fetch) would be reasonable.

i am testing a collection with about 40000 entity...actually in my application, after a user create a new object or modify or delete....i refresh my collection again (because maybe other user also add or modify an object so i have to refresh the collection)....and the problem is if everytime i refresh a collection after add, modify......it take a few second to reload all the objects and the UI was paused...

I see in developer express XPO....it work very well with load the changed object only....

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 29-Jan-2010 11:07:08   

i am testing a collection with about 400000 entity

Waw....400,000 entities are too much to have in a collection in memory. Why do you need all these entities in memory, I'm sure you can't display all these entities to the user in one screen.

It would be better if you keep the entities in the database and not in memory. And then you can only fetch a small portion (page) of those entities you need to display.

Only then a complete re-fetch would be much easier.

but what about deleted objects? have any idea?

For these requirement, I can only think of a Client/Server Design. Where if you want you may cache the collection in the memory of the Server, and then whenever a client deletes an entity, updates one or adds a new one, the Server can let other connected Clients know about this change so they can update their views.

holife
User
Posts: 3
Joined: 26-Jan-2010
# Posted on: 29-Jan-2010 11:28:55   

Walaa wrote:

i am testing a collection with about 400000 entity

Waw....400,000 entities are too much to have in a collection in memory. Why do you need all these entities in memory, I'm sure you can't display all these entities to the user in one screen.

It would be better if you keep the entities in the database and not in memory. And then you can only fetch a small portion (page) of those entities you need to display.

Only then a complete re-fetch would be much easier.

but what about deleted objects? have any idea?

For these requirement, I can only think of a Client/Server Design. Where if you want you may cache the collection in the memory of the Server, and then whenever a client deletes an entity, updates one or adds a new one, the Server can let other connected Clients know about this change so they can update their views.

LOL, my wrong...actually, i mean 40000 entities only....haha... i see....i will think about it later....thanks anyway...