logcache: fixed sql