Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:57:33+00:00 2026-05-25T01:57:33+00:00

Currently I am trying to integrate db4o into my App. I have a Model

  • 0

Currently I am trying to integrate db4o into my App. I have a Model which contains – lets say 15 primitives – wrapped in other Objects. storing them is easy and fast, but to recieve them is pain. I tried NativeQuerys and SODA without any big difference. To give some of them an Index slows the query even more down.

in Example: I have a query looking like this:

    public List<DatabaseReport> getCurrentDeviationReportsOnly(){
    final long now = System.currentTimeMillis();
    return getDatabase().query(new Predicate<DatabaseReport>() {
        @Override
        public boolean match(DatabaseReport candidate) {
            return candidate.getReport().getBegin().getMillis() < now
                && candidate.getReport().getEnd().getMillis() > now;
        }
    }, mTimeComparator);

mTimeComparator is implemented as following:

public static class DatabaseScheduleReportTimeComparator implements Comparator<DatabaseReport>{

    @Override
    public int compare(DatabaseReport object1,
            DatabaseReport object2) {

        long first = object1.getReport().getBegin().getMillis();
        long second = object2.getReport().getBegin().getMillis();
        if (first < second) return 1;
        if (first > second) return -1;
        else {
            first = object1.getReport().getEnd().getMillis();
            second = object2.getReport().getEnd().getMillis();
            if (first > second) return 1;
            if (first < second) return -1;
            else return 0;
        }

so with the Query above I expect to recievce like 40 of 100 Reports stored. I measured time for query and activation, and its about 3,5 SECONDS!!! For me, this seems VERY slow!
I played around a little and removed the Comparator in my query. Now I have an execution-time of about 1,2 Seconds. If I sort them manually with Collections.sort(myInstantiatedDatabaseReportList, mTimeComparator) it executes in 47 Millis!! Am I doing something wrong? What is the reason that db4o likes to take more than 10 times more time than Collections.sort()?

What is the best way to optimize my model for db4o? (Activatable is not usefull in this case because the ResultingList will be passed in an ListAdapter, which needs every single member.)

Edit: due to the Answer below, I insert my SodaQuery here, too:

public List<DatabaseReport> getCurrentDeviationReports(){
    final Date now = new Date(System.currentTimeMillis());

    Query query = getDatabase().query();
    query.constrain(DatabaseReport.class);
    query.descend("mReport").descend("begin").descend("datetime").constrain(now).smaller();
    query.descend("mReport").descend("end").descend("datetime").constrain(now).greater();
    query.descend("mReport").descend("begin").descend("datetime").orderAscending();
    query.descend("mReport").descend("end").descend("datetime").orderDescending();
    return query.execute();

}

so the “datetime” here is a java.util.date Object. As I wrote above, it seems to me that indexing makes it SLOWER!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:57:34+00:00Added an answer on May 25, 2026 at 1:57 am

    There are multiple things which could go wrong. So here’s my check-list.

    • Make sure that every field along this navigation is indexed. The ‘report’, ‘begin’ field and the ‘millis’ field.
    • Is any of these fields a interface or a generic type? Then db4o won’t use a index. You need concrete types so that db4o can find out what type the field is and use the indexes.
    • When you’re using native queries on Android, not that then you need to optimize these at built time. The reason is that the query optimizer cannot deal with
    • Whats the type returned by getBegin()? If its a regular Java date, then the native optimizer doesn’t do greater / smaller than comparisons. That only works with SODA
    • The query returns 40 of 100 object? Then the sorting shouldn’t be a big issue.
    • SODA is also slow? That a little strange. Can you show me your SODA query?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to integrate some OpenCV functionality into my application. Currently I have
I have a classifieds website which I am now trying to integrate SOLR into,
We're currently trying to integrate existing classic ASP pages into our new method of
I have an IRC client application and I am currently trying to integrate it
I'm currently trying to integrate some animation drawing code of mine into a third
I am trying to integrate the AddressBookUI API into my iOS 5 app to
I currently trying to decide which embedded database to pick up for new .NET
I am currently trying to copy an array I have to a new view
I am currently trying to integrate a RIch Text Editor in an application I
I'm trying to integrate a script file hosted by a third party into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.