updated sql precomputation