On Tue, Dec 15, 2015 at 11:19 PM, Dominique Pell? <dominique.pelle at gmail.com
> wrote:

> ??? <2004wqg2008 at 163.com> wrote:
>
> >
> >         After testing the Sqlite3_open and ATTACH DATABASE,
> >         I found that the attach database is slower than sqlite3_open.
> >         there is attachment after the mail which includ the speed
> >         information ( millisecond ).
>
>
> Your attachment was discarded (attachment not allowed in this
> mailing list).
>
> Anyway, I remember observing that:
>
> - sqlite3_open_v2(...) is lazy.  In other words, it does not parse the
>   schema of the DB until the first query is performed after opening
>   the database.
> - ATTACH is not lazy. The schema is parsed as soon as you
>   attach a database.
>
> That could explain the difference in speed.
> Would there be a way to make ATTACH lazy by the way?
>

Why would that be of benefit to you? Are you intending to attach a database
and never use it? It seems to me the same amount of time will be taken
either way.

When it comes to opening a database, there may be a need to do some
connection specific configuration prior to actually opening the database
file and parsing the schema. I believe this is the reason why open defers
that processing until later, giving you a chance to finish configuring your
connection before locking it down. Once that configuration is complete,
there is no advantage to deferring the open of the database.

I say no advantage ... maybe I just can't think of one. Why do you think
there would be an advantage to deferring the open & schema processing of an
attached database?

-- 
Scott Robison

Reply via email to