I have a process where at some point I got to add a new column to a table of type INTEGER, then I got to populate this new column with an UPDATE. I do this in C.
I can lean down my code to
CREATE table t (a integer, b integer)
populate t
CREATE INDEX t_ndx on t (a)
ALTER TABLE t add c integer
The C pseudo code to update the column 'c' look like this
sqlite3_stmt u;
sqlite3_prepare_v2(db, "update t set c=? where a=?, -1, &u, 0);
for(i=0;i<n;i++)
{ c=c_a[i];
a=a_a[i];
sqlite3_bind_int64(u, 1, c);
sqlite3_bind_int64(u, 1, a);
sqlite3_step(u);
}
The order of a's are the same for this UPDATE as the one given when t was created.
I'd like to know if the sqlite3 engine detect the 'sequential' access and do speed up the "where a=?" (i.e keep a kind of caching of previous cursor ?
I'd like to know as well if there are 'hidden' feature like binding array's (at least when dealing witn INTEGERs) to avoid construct such a loop and avoid all those bindings and avoid the bytecode for doing all those insert something along the line of
sqlite3_stmt u;
sqlite3_prepare_v2(db, "update t set c=? where a=?, -1, &u, 0);
sqlite3_bind_int64_array(u, 1, c_a, n);
sqlite3_bind_int64_array(u, 1, a_a, n);
sqlite3_step_array(u,n);
Thanx in advance Cheers Phi
Aucun commentaire:
Enregistrer un commentaire