Refactoring of query store