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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:59:17+00:00 2026-05-25T23:59:17+00:00

Without getting into too much detail, I have a process in my iOS app

  • 0

Without getting into too much detail, I have a process in my iOS app that parses XML and inserts (sometimes up to 10s or 100s of) thousands of records into an Sqlite3 table.

For speed, I have no indexes on the table, and I’m inserting records into an in memory temporary table first then moving them over to the final table in batches of 400. Neither the temporary table or filesystem table have any indexes.

The problem I’m noticing is that at the beginning of the process, it takes about a 10th of a second to flush the 400 records to disk. Then with each flush, it takes longer and longer, where after a minute or two, it’s taking 3 seconds to flush the 400 records. The longer it goes, the longer it takes. Each flush takes about a 1 to 2 tenths of a second longer than the previous one.

Since I’m not using any indexes, can anyone explain why this is happening and recommend a solution?

Update 1:
I tried setting PRAGMA syncronous = OFF; and while that sped things up a little, it still get a fraction of a second slower with every INSERT SELECT to the point where it is multiple seconds for every flush after a few thousand rows. I’ll keep trying other optimizations to see if I can get to the bottom of this…

Update 2:
Clarification on what I’m doing: I’m inserting the records as they are parsed into a temporary table that’s in memory until the count reaches 400 as counted by an int in Objective-C code. Once the record count is 400, I’m doing a single INSERT SELECT to move the rows into the table on disk, then I’m doing a DELETE * from the memory table. I’m timing each part. Sqlite3 optimizes DELETE * when it has no WHERE clause so that it’s like dropping and recreating the table, and it is very quick, less than 100th of a second. It’s only the INSERT SELECT from the memory table to the disk table that is decreasing in speed each time. That query starts out taking about 0.1 seconds, and after each batch of 400 records that is inserted, the query takes about .1 to .2 seconds longer than the last one, until it’s eventually taking multiple seconds to move the 400 rows from memory to disk each time.

Update 3: Here are my table creation statements and the statement I’m using to move records from memory to disk. There are no keys at all. And yes my sqlite is configured so that the temporary table is in memory not disk.

The temporary table in memory:

  1. CREATE TEMPORARY TABLE allSongsTemp (title TEXT, songId TEXT, artist TEXT, album TEXT, genre TEXT, coverArtId TEXT, path TEXT, suffix TEXT, transcodedSuffix TEXT, duration INTEGER, bitRate INTEGER, track INTEGER, year INTEGER, size INTEGER);

The table on disk:

  1. CREATE TABLE allSongsUnsorted (title TEXT, songId TEXT, artist TEXT, album TEXT, genre TEXT, coverArtId TEXT, path TEXT, suffix TEXT, transcodedSuffix TEXT, duration INTEGER, bitRate INTEGER, track INTEGER, year INTEGER, size INTEGER);

The queries to flush the memory records to disk:

  1. INSERT INTO allSongsUnsorted SELECT * FROM allSongsTemp;

  2. DELETE * FROM allSongsTemp;

The query that is taking longer and longer each time is #3, the INSERT SELECT. The DELETE takes about 1/100th of a second each time.

  • 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-25T23:59:18+00:00Added an answer on May 25, 2026 at 11:59 pm

    Larry Lustig called it in the comments to the question, but doesn’t seem to be around anymore to create an answer.

    Dropping and re-creating the table instead of doing DELETE * did the trick. It seems that though the delete was quick, it was causing some kind of fragmentation in memory that was slowing down each subsequent read. Unless I misread the sqlite3 docs, a DELETE * is supposed to be optimized as a DROP; CREATE; but it seems that may not be exectly the case for temporary memory tables (or maybe even filesystem tables, but I would need to test that to verify as this issue could very well only affect memory tables).

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

Sidebar

Related Questions

On his blog Scott Kovatch writes: Without getting into too much detail, typing ‘java
without getting too verbose....i have been learning AS3 over the last week by building
I have a portion of a bash script that is getting a filename without
We would like to decrypt data stored in Microsoft Access. Without getting into too
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
Without getting into a discussion about whether the business logic should be in the
Not getting into too many specifics, this is a high level question. I've always
My organization is getting into mobile development. I'd like to have 1 icon on
Without getting a degree in information retrieval, I'd like to know if there exists
I understand recursive mutex allows mutex to be locked more than once without getting

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.