Thanks for everyone.
You are right. According to you help, I understand the problem.
 Just open or attach database , open operation is faster than attach database.
 if add a query statement after open or attach database. The time which they 
cost almost the same.

 Best regards.
 what Dominique  said is right. As following:


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?



Regards

Dominique











At 2015-12-16 18:27:34, "Dan Kennedy" <danielk1977 at gmail.com> wrote:
>On 12/16/2015 12:51 PM, ??? 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 ).
>
>Hi,
>
>This mailing list strips attachments, so you'll need to include the 
>information inline.
>
>One possible explanation: When you run an ATTACH statement, SQLite opens 
>the new database file and reads the schema from the sqlite_master table. 
>Whereas sqlite3_open() just opens the db file (reading the schema is 
>deferred until it is first required in this case).
>
>So an apples/apples comparison might be to open/ATTACH the database and 
>then run a simple query that forces SQLite to read the database schema 
>if it has not already - say "SELECT * FROM sqlite_master".
>
>Dan.
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users at mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to