From 2f054f91fc25d367a7a058ad195a4299d81a783e Mon Sep 17 00:00:00 2001 From: antleb Date: Thu, 15 Feb 2024 13:04:46 +0200 Subject: [PATCH] added an index on cache key --- .../di/madgik/statstool/repositories/StatsDBRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java b/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java index ceb4a05..7fd02f4 100644 --- a/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java +++ b/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java @@ -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 @@ -196,7 +198,7 @@ public Map stats() { Map 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;