add sql for precompute tables