I'll look into GLOB. For the statement cloning, I'm looking for something a little different. I already have the connection and query string, and duplicating bindings is not necessary. It's the sqlite3_stmt that I want. right after sqlite3_prepare_v2 has been called.
I was doing some profiling today. My statement loads one record by rsn, and then parses that data into an external object. Just calling sqlite3_prepare_v2 takes 3-4x as long as stepping, reading, and parsing the record. This particular request is very simple, and the only thing that changes is the rowid which is handled with a bind. So, if I could prepare the statement once, then clone it every time I need to use it, I may see a 4 fold speed increase when calling this operation frequently. The query is basically "Select * from tableName where rowid=?" Thanks dw On Apr 19, 2011, at 4:40 PM, Mihai Militaru wrote: > On Tue, 19 Apr 2011 14:18:05 -0600 > Dave White <dwh...@companioncorp.com> wrote: > >> For example, this works: >> SELECT T01_fts.docid FROM T01_fts JOIN T01 ON T01_fts.docid = T01.rowid >> WHERE T01.hasPic = 0 AND T01_fts.words MATCH 'SBNTKN*' >> >> These do not: >> SELECT T01_fts.docid FROM T01_fts JOIN T01 ON T01_fts.docid = T01.rowid >> WHERE T01.hasPic = 0 OR T01_fts.words MATCH 'SBNTKN*' >> SELECT T01_fts.docid FROM T01_fts JOIN T01 ON T01_fts.docid = T01.rowid >> WHERE T01.hasPic = 0 AND (T01_fts.words MATCH 'SBNTKN*' OR T01_fts.words >> MATCH 'CTLTKN*' ) > > I think it is GLOB '*' what you look for (or LIKE '%' for case-insensitive > match): > SELECT T01_fts.docid FROM T01_fts JOIN T01 ON T01_fts.docid = T01.rowid WHERE > T01.hasPic = 0 OR T01_fts.words GLOB 'SBNTKN*'; > SELECT T01_fts.docid FROM T01_fts JOIN T01 ON T01_fts.docid = T01.rowid WHERE > T01.hasPic = 0 AND (T01_fts.words GLOB 'SBNTKN*' OR T01_fts.words GLOB > 'CTLTKN*'); > >> And an entirely separate question: Is there currently a way, or will there >> soon be a way to clone prepared statements? > > I'd do it like this: > > sqlite3_stmt *stmt2 = NULL; > sqlite3_prepare_v2(sqlite3_db_handle(stmt1), sqlite3_sql(stmt1), -1, &stmt2, > NULL); > > Check what the respective functions do here: > http://www.sqlite.org/c3ref/funclist.html > Basically: > - the first argument function returns the database of the first statement > (you may pass a different open database handle directly, > in order to "clone" the first statement over it); > - the second argument function returns the sql text of the first statement; > - the third argument is the size of the text to parse, negative to get it up > to the first NULL - normally the end; > - the fourth is a pointer to your new unallocated statement; > > I think copying the bindings is possible using sqlite3_bind_parameter_* and > something else I can't figure out right now. > > -- > Mihai Militaru <mihai.milit...@xmpp.ro> > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users