Thanks! It sounds pretty good. But I don't understand it exactly. Could you write down the sample codes?
Matthew L. Creech wrote: > > On Mon, Apr 27, 2009 at 10:25 PM, liubin liu <7101...@sina.com> wrote: >> >> thanks >> >> I'm not sure of the real reason. >> It's true that the speed of inserting with transaction is very fast. But >> my >> project is using SQLite mainly in selecting something. I don't know how >> to >> use transaction in the situation. May some friends give me some codes on >> that? >> > As someone else mentioned, you probably don't want to open/close the > database every time you do a single SELECT. In the example you're > doing 100,000 iterations of open/exec/close, which will give pretty > terrible performance. > > Instead, try creating an initialization call, which opens the > database, prepare()s your SELECT stmt (with a '?' placeholder for the > ID in this example), and returns a handle to the caller. The caller > can then loop 100,000 times calling getdata() with this handle. > getdata() can just do sqlite3_bind_XXX() followed by sqlite3_step() > (and sqlite3_reset()), which will be _much_ faster than > sqlite3_exec(). > > -- > Matthew L. Creech > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://www.nabble.com/speed-test%2C-Sqlite3-vs-BerkeleyDB%2C-I%27m-confused-tp23209208p23271593.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users