Skip to content

Commit

Permalink
added an index on cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
antleb committed Feb 15, 2024
1 parent 5573a2a commit 2f054f9
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public void postInit() {
"total_hits int default 0 not null," +
"session_hits int default 0 not null," +
"pinned boolean default false not null)");

jdbcTemplate.execute("create index key_idx on cache_entry(key)");
}

@Override
Expand Down Expand Up @@ -196,7 +198,7 @@ public Map<String, Object> stats() {
Map<String, Object> stats = new LinkedHashMap<>();

stats.put("total", jdbcTemplate.queryForObject("select count(*) from cache_entry",new Object[] {}, Integer.class));
stats.put("with_shadow", jdbcTemplate.queryForObject("select count(*) from cache_entry where shadow is not null",new Object[] {}, Integer.class));
stats.put("with_shadow", jdbcTemplate.queryForObject("select count(*) from cache_entry where shadow is not null and shadow != ''",new Object[] {}, Integer.class));
stats.put("total.top10", jdbcTemplate.query("select * from cache_entry where key not in ('SHADOW_STATS_NUMBERS', 'STATS_NUMBERS') order by total_hits limit 10", (rs, rowNum) -> {
CacheEntry entry = null;

Expand Down

0 comments on commit 2f054f9

Please sign in to comment.