add caching on subtable queries