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 9001737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:28:35+00:00 2026-06-16T00:28:35+00:00

I am attempting to insert rows into a SQLite DB. It takes 7 seconds

  • 0

I am attempting to insert rows into a SQLite DB. It takes 7 seconds to insert 130 rows, this seems slow to me.

Table definition is :

    sd.execSQL("CREATE TABLE " + V2VocabsTable.TABLE_NAME + " (" 
            + V2VocabsTable.ID   + " VARCHAR(10) PRIMARY KEY ," 
            + V2VocabsTable.NAME    + " VARCHAR(255), " 
            + V2VocabsTable.LOADED  + " VARCHAR(1) " 
            + ");"
            );

To insert a row I use the following code :

public void addTableStatus(String tableId, String name) {

    Log.d("DB","Before Insert");

    ContentValues cv = new ContentValues();
    cv.put(V2VocabsTable.ID, "Table " + tableId);
    cv.put(V2VocabsTable.NAME, name);
    cv.put(V2VocabsTable.LOADED, "NO");
    SQLiteDatabase sd = getWritableDatabase();
    long result = sd.insert(V2VocabsTable.TABLE_NAME,   null, cv);

    Log.d("DB","After Insert :: " + result);
    }

Times in the log file are :

 12-17 23:00:11.445: D/SQLDB(25384): Init
 12-17 23:00:11.455: D/DB(25384): Before Insert
 12-17 23:00:11.505: D/SQLDB(25384): Open
 12-17 23:00:11.895: D/DB(25384): After Insert :: 1
 12-17 23:00:11.895: D/DB(25384): 0001 :: AdministrativeSex-v1.0.xml
 12-17 23:00:11.895: D/DB(25384): Before Insert
 12-17 23:00:11.965: D/DB(25384): After Insert :: 2
 12-17 23:00:11.965: D/DB(25384): 0002 :: MaritalStatus-v1.0.xml
 12-17 23:00:11.965: D/DB(25384): Before Insert
 12-17 23:00:12.005: D/DB(25384): After Insert :: 3
 12-17 23:00:12.005: D/DB(25384): 0004 :: PatientClass-v1.0.xml
 12-17 23:00:12.005: D/DB(25384): Before Insert
 12-17 23:00:12.145: D/DB(25384): After Insert :: 4

 12-17 23:00:18.815: D/DB(25384): Before Insert
 12-17 23:00:18.865: D/DB(25384): After Insert :: 131
 12-17 23:00:18.865: D/DB(25384): ZU057 :: LocationHiding-v1.0.xml
 12-17 23:00:18.865: D/DB(25384): Before Insert
 12-17 23:00:18.925: D/DB(25384): After Insert :: 132

This seems excessively slow to me, what could be slowing it down?

  • 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-16T00:28:35+00:00Added an answer on June 16, 2026 at 12:28 am
    public DataBase openWithTrans() throws SQLException {
        ourHelper = new DataBaseHelper(ourContext, DATABASE_NAME,
                DATABASE_LOCATION);
        db = ourHelper.getWritableDatabase();
        db.beginTransaction();
        return this;
    }
    
    public void closeWithTrans() {
        try {
    
            db.setTransactionSuccessful();
    
    
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
    
            db.endTransaction();
            Debug.debugMsg("end trans successful");
            db.close();
            Debug.debugMsg("close db successful");
            if (ourHelper != null) {
                ourHelper.close();
            }
        }
    
    }
    

    The above code will will enable you to do transaction. In transcation mode you should be able to increase your speed up by a lot. And as comment pointed out, you start transaction then insert your x number of rows then close it.

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

Sidebar

Related Questions

I am attempting to insert data into a local SQLITE database file from a
Attempting to insert an escape character into a table results in a warning. For
I'm attempting to insert some integers into a Postgres table with the following somewhat
In SSMS 2008 R2 I execute: create table aaa(col1 xml); go insert into aaa
I am attempting to insert about 30k rows of data into a database. The
I am attempting to insert an input button into an HTML table using .innerHTML
I am attempting to insert a row manually into my SQL Server data table.
I'm attempting to insert rows into a SQL Server CE database, and it's returning
I am attempting to insert a new record into a table that I know
I've a MySQL table that has a UTF-8 charset and upon attempting to insert

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.