[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: SQLite and callbacks

From: Stefan Sperling <stsp_at_elego.de>
Date: Mon, 7 Feb 2011 17:28:36 +0100

On Mon, Feb 07, 2011 at 05:18:57PM +0100, Stefan Sperling wrote:
> On Mon, Feb 07, 2011 at 10:55:47AM -0500, Mark Phippard wrote:
> > On Mon, Feb 7, 2011 at 10:52 AM, Stefan Sperling <stsp_at_elego.de> wrote:
> >
> > > Where is the temporary table stored? Is it back by a file or memory?
> > > If backed by memory, do we have to worry about memory consumption for
> > > large working copies?
> >
> > The patch says it is backed by a file.
>
> Yes, it does say that in a comment but I didn't see where this is being
> enforced in the code.
> Checking the sqlite docs gave the answer:
>
> "When the name of the database file handed to sqlite3_open() or to ATTACH
> is an empty string, then a new temporary file is created to hold the
> database."
> http://sqlite.org/inmemorydb.html
>
> This is what the patch does:
>
> +-- STMT_ATTACH_TEMPORARY_DATABASE
> +ATTACH DATABASE '' AS temp_query_cache;
>
> And note that the sqlite docs also say:
>
> "Even though a disk file is allocated for each temporary database, in
> practice the temporary database usually resides in the in-memory pager
> cache and hence is very little difference between a pure in-memory
> database created by ":memory:" and a temporary database created by an
> empty filename. The sole difference is that a ":memory:" database must
> remain in memory at all times whereas parts of a temporary database
> might be flushed to disk if database becomes large or if SQLite comes
> under memory pressure."
>
> Neat :)

Actually, we are forcing all temporary databases to be pure memory
in svn_sqlite__open():

  /* Store temporary tables in RAM instead of in temporary files, but don't
     fail on this if this option is disabled in the sqlite compilation by
     setting SQLITE_TEMP_STORE to 0 (always to disk) */
  svn_error_clear(exec_sql(*db, "PRAGMA temp_store = MEMORY;"));

Is this really a good idea? I think we should set it to FILE by default.
http://sqlite.org/pragma.html#pragma_temp_store
Received on 2011-02-07 17:29:26 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.