• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SQLite optimization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SQLite optimization


  • Subject: Re: SQLite optimization
  • From: Kevin Van Vechten <email@hidden>
  • Date: Mon, 28 Aug 2006 16:08:02 -0700

On Aug 28, 2006, at 3:48 AM, Mark Gilbert wrote:
My app accesses the same SQlite database from several threads, and in order to accommodate this I currently open and close the database on each access, and the various threads will wait when the database is busy on another thread.

First, I'd recommend asking SQLite-specific questions on the relevant SQLite mailing list(s) at <http://www.sqlite.org/> -- that's where you'll find the experts.


<http://www.sqlite.org/faq.html#q8> says:

(8) Is SQLite threadsafe?

Yes. Sometimes. In order to be thread-safe, SQLite must be compiled with the THREADSAFE preprocessor macro set to 1. In the default distribution, the windows binaries are compiled to be threadsafe but the linux binaries are not. If you want to change this, you'll have to recompile.

"Threadsafe" in the previous paragraph means that two or more threads can run SQLite at the same time on different "sqlite3" structures returned from separate calls to sqlite3_open(). It is never safe to use the same sqlite3 structure pointer in two or more threads.

So the relevant question for this list is, "Was SQLite compiled threadsafe?" Taking a look at <http://www.opensource.apple.com/ darwinsource/10.4.7.ppc/SQLite-28/Makefile> shows "--enable- threadsafe" is used in the configuration options -- so I believe it is.


Therefore, you don't need to repeatedly call open and close -- you just need to have one open per thread and SQLite will take care of the rest of the synchronization.

- Kevin

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >SQLite optimization (From: Mark Gilbert <email@hidden>)

  • Prev by Date: Re: MACFORGE request for a project
  • Next by Date: Re: SQLite optimization
  • Previous by thread: Re: SQLite optimization
  • Next by thread: Re: SQLite optimization
  • Index(es):
    • Date
    • Thread