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

  • Home
  • SEARCH
  • 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 8313659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:33:52+00:00 2026-06-08T20:33:52+00:00

Calling the ORMLite RuntimeExceptionDao ‘s createOrUpdate(…) method in my app is very slow. I

  • 0

Calling the ORMLite RuntimeExceptionDao‘s createOrUpdate(...) method in my app is very slow.

I have a very simple object (Item) with a 2 ints (one is the generatedId), a String and a double. I test the time it takes (roughly) to update the object in the database (a 100 times) with the code below. The log statement logs:

time to update 1 row 100 times: 3069

Why does it take 3 seconds to update an object 100 times, in a table with only 1 row. Is this the normal ORMLite speed? If not, what might be the problem?

RuntimeExceptionDao<Item, Integer> dao =
    DatabaseManager.getInstance().getHelper().getReadingStateDao();
Item item = new Item();
long start = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
    item.setViewMode(i);
    dao.createOrUpdate(item);
}
long update = System.currentTimeMillis();
Log.v(TAG, "time to update 1 row 100 times: " + (update - start));

If I create 100 new rows then the speed is even slower.

Note: I am already using ormlite_config.txt. It logs "Loaded configuration for class ...Item" so this is not the problem.

Thanks.

  • 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-06-08T20:33:55+00:00Added an answer on June 8, 2026 at 8:33 pm

    This may be the “expected” speed unfortunately. Make sure you are using ORMLite version 4.39 or higher. createOrUpdate(...) was using a more expensive method to test for existing of the object in the database beforehand. But I suspect this is going to be a minimal speed improvement.

    If I create 100 new rows then the speed is even slower.

    By default Sqlite is in auto-commit mode. One thing to try is to wrap your inserts (or your createOrUpdates) using the the ORMLite Dao.callBatchTasks(...) method.

    In by BulkInsertsTest android unit test, the following doInserts(...) method inserts 1000 items. When I just call it:

    doInserts(dao);
    

    It takes 7.3 seconds in my emulator. If I call using the callBatchTasks(...) method which wraps a transactions around the call in Android Sqlite:

    dao.callBatchTasks(new Callable<Void>() {
        public Void call() throws Exception {
            doInserts(dao);
            return null;
        }
    });
    

    It takes 1.6 seconds. The same performance can be had by using the dao.setSavePoint(...) method. This starts a transaction but is not as good as the callBachTasks(...) method because you have to make sure you close your own transaction:

    DatabaseConnection conn = dao.startThreadConnection();
    Savepoint savePoint = null;
    try {
        savePoint = conn.setSavePoint(null);
        doInserts(dao);
    } finally {
        // commit at the end
        conn.commit(savePoint);
        dao.endThreadConnection(conn);
    }
    

    This also takes ~1.7 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Calling expert Scala developers! Let's say you have a large object representing a writable
Calling the WriteObject Method from a background thread is not possible! Is there a
Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
Calling Index view is giving me this very very annoying error . Can anybody
Calling all AutoMapper gurus! I'd like to be able to map object A to
While calling XslCompiledTransform.Transform() method I get this exception : The Writer is closed or
Calling all MQ Gurus, I have a box under my desk which we use
calling .center() makes the panel center on the entire page.. I'd like to have
Calling a GUI app using [DllImport( advapi32.dll, EntryPoint = CreateProcessAsUser, SetLastError = true, CharSet
calling ListView's setSelection() seems to have a problem. a lot of people ask about

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.