probcomp / bayeslite

BayesDB on SQLite. A Bayesian database table for querying the probable implications of data as easily as SQL databases query the data itself.
http://probcomp.csail.mit.edu/software/bayesdb
Apache License 2.0
923 stars 63 forks source link

sqlite3 multiply evaluates functions needlessly #308

Open riastradh-probcomp opened 9 years ago

riastradh-probcomp commented 9 years ago

For some reason, sqlite3 repeats evaluation of the same function calls for each row in a query, so, e.g.,

ESTIMATE MUTUAL INFORMATION AS mutinf
    FROM PAIRWISE COLUMNS OF t
    ORDER BY mutinf

evaluates mutual information for each pair of columns twice (actually, four times, because mutual information is symmetric, but that's a separate issue). Using a subquery avoids the problem:

SELECT *
    FROM (ESTIMATE MUTUAL INFORMATION AS mutinf
            FROM PAIRWISE COLUMNS OF t)
    ORDER BY mutinf

But this is silly. I looked into this briefly in sqlite3 but didn't find any obvious information about how to make sqlite3 save the result -- especially if it's already going to be stored in the result table anyway!

gregory-marton commented 8 years ago

259 seems like the same underlying issue.