The Artima Developer Community
Sponsored Link

Java Answers Forum
Search result with 100.000 objects

1 reply on 1 page. Most recent reply: Feb 9, 2005 5:30 AM by John Neale

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Brian Grey

Posts: 3
Nickname: ngok
Registered: Feb, 2005

Search result with 100.000 objects Posted: Feb 6, 2005 8:22 AM
Reply to this message Reply
Advertisement
Here is my problem:

In my web application deployed on Tomcat, there is a search page that can retrieve all “objects” from an Oracle database. These “objects” are phone cards objects that have properties like phone number, profile, etc…

The client can have 100.000, 200.000 cards or more in the system. Actually when the client wants to see the result of his search, the system displays it in pages with 15 “objects” (or “cards”) per page. On the top of the page there is a direct link of the other pages. So the client can navigate trough all pages using these links or using the previous/next buttons.
The problem is: when the client doesn’t put any criteria into the search page (meaning that he’s going to get all “objects” (= can be 10.000, 100.000 or more)), the system returns “out of memory” after a few long minutes.
The search functionality returns a collection of objects. A “page iterator” splits it into several pages. I think that the collection that contains the result cannot handle it.
By the way, I’m using Kodo as a “persistence manager”.

Here is the method that retrieves all objects from a search (with an empty filter in this case)
protected Collection execute(Class type, String filter) {

final Extent extent = getPersistenceManager().getExtent(type, true);
query = pm.newQuery(extent, filter);
query.setOrdering(orderBy + " " + (orderAscending ? "ascending" : "decending"));

final Collection result = (Collection) query.execute();
return result;
}

Thanks


John Neale

Posts: 10
Nickname: rhino
Registered: Oct, 2003

Re: Search result with 100.000 objects Posted: Feb 9, 2005 5:30 AM
Reply to this message Reply
Brian,

You need to change the way you are handling queries. Your basic problem is you are trying to instantiate many thousands of objects and this is causing the Out of Memory and will also cause the application to be very slow. Instead you need to only instantiate the objects you need at the time. This means introducing some sort of pagination into database access that is similar to the pagination of the web page.

You easiest way to do this is to have a navigatible cursor to your database. These way you can jump through the resultset however the customer wants and before you display each page you simply retrieve the rows you need from the database when you need them.

I am not familiar with Kodo so I can't give you specifics but I hope I've given you a mechanism to pursue.

Flat View: This topic has 1 reply on 1 page
Topic: KODO count(*) Previous Topic   Next Topic Topic: Multiple Screens/Monitors

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use