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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:11:18+00:00 2026-06-02T09:11:18+00:00

I am inserting a few rows with in a transaction. But when I do

  • 0

I am inserting a few rows with in a transaction. But when I do a ‘END TRANSACTION’ its taking around 250ms to execute while the ‘BEGIN TRANSACTION’ hardly takes around 1ms. I need to fasten the speed here to suite my application. How can I?

[edit]
* A single thread is accessing the database.
* I have 2 tables in this database and both these have primary key on them.
* With in a transaction there is exactly one insert into each the tables.
* OS – windows 7

  • 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-02T09:11:19+00:00Added an answer on June 2, 2026 at 9:11 am

    Using the out of the box, or default, settings of sqlite, 250ms to commit a transaction makes sense. This is due to how sqlite commits your transaction. It waits for the VFS for a guarantee that the writes are committed to disk to return.

    Here are a couple of possibilities to optimize.

    Encapsulate more inserts per transaction

    If possible, execute more inserts per transaction. Try running, say, 100 inserts in one transactions, and see how little difference there will be compared to only 1 insert. You may not even see any (i.e. 100 inserts will probably take marginally more than 250ms).

    Bottom line is that you’ll get more bang for your buck as each insert will ultimately take less time (on average).

    Use WAL journaling

    I strongly recommend you try WAL journaling as you should see a dramatic reduction from 250ms. WAL shouldn’t be any less safe than regular journaling. The reason WAL is faster is in its name: it appends to a journaling file instead of having the database file absorb the changes of your commit every time you commit. Read this for the full story.

    To activate WAL journaling, set the journal_mode pragma to WAL:

    PRAGMA journal_mode = WAL;
    

    Change the synchronous pragma

    This may or may not be good enough for you as it is less safe. As such, I recommend it only if you understand what the risks are, and also if the two previous suggestions are not good enough for you, or if you cannot use them.

    Basically, changing the synchronous pragma to NORMAL or OFF will cause sqlite to not wait after the VFS for a guarantee that the writes are committed to disk to return.

    Please read the documentation first, then if you still want to try it, you can set your pragma to either OFF or NORMAL:

    PRAGMA synchronous = NORMAL;
    

    or

    PRAGMA synchronous = OFF;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inserting rows one by one from a 600 record data-set is taking almost an
While inserting rows into SQL Server CE in WP7 I'm getting a SQLCeException that
How do you get around the exponential conversion that takes place when inserting a
I am using HTML 5 to develop a few things and inserting Facebook JavaScript
After inserting new html to DOM,I need to add some listeners to it. But
Changing and finding stuff in a database containing a few dozen tables with around
I create a simple window with a comboboxex (with inserting few bitmaps), I need
I have come a across a few different methods for inserting data into SQL
I am inserting rows into a table from a Powershell script. I loop through
In MS SQL Server 2008, inserting Rows into a table variable became painfully slow

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.