Hi all,
I have a table with matrices stored as blobs. Each matrix has about 800 bytes. This table has between 20,000 and 500,000 rows. I use a custom function "EXPENSIVE_FUNCTION" which performs a calculation using a matrix supplied via sqlite3_bind_pointer() as ?99 and the matrix in the vdata column. I create the function using the SQLITE_DETERMINISTIC flag. My hope was that the EXPENSIVE_FUNCTION is called only once per row. But that's not the case. The query looks like this: UPDATE some_table SET vdist = EXPENSIVE_FUNCTION(?99,vdata), oid = ?1, flags = flags | (CASE WHEN EXPENSIVE_FUNCTION(?99,vdata) < ?2 THEN ?3 ELSE 0 END) WHERE (flags & ?3) = 0 AND (oid IS NULL AND EXPENSIVE_FUNCTION(?99,vdata) < 0.6) OR (EXPENSIVE_FUNCTION(?99,vdata) < vdist) The EXPENSIVE_FUNCTION function is referred multiple times in the update statement. But it always returns the same result (for any given row). My stats report that SQLite calls EXPENSIVE_FUNCTION 91,806 times for a table with 45,775 rows. 256 rows are modified. This takes (only) 3.3 seconds. The profiler tells me that sqlite3VdbeExec() spends 47% in vdbeMemFromBtreeResize and 36% in EXPENSIVE_FUNCTION. Can I change something so SQLite calls EXPENSIVE_FUNCTION only once per row? Thanks in advance. -- Mario _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users