From 146a06ec745d36e9fde955034a8468f133700900 Mon Sep 17 00:00:00 2001 From: antleb Date: Thu, 23 Jan 2025 09:18:20 +0000 Subject: [PATCH] properly creating index only if it doesn't already exists --- .../di/madgik/statstool/repositories/StatsDBRepository.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 547d5a8..d705f5d 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 @@ -55,10 +55,7 @@ public void postInit() { "exectime int default 0 not null," + "profile varchar(100) not null)"); - boolean indexExists = jdbcTemplate.queryForObject("select count(*) from INFORMATION_SCHEMA.SYSTEM_INDEXINFO where table_name='cache_entry' and index_name='key_idx'", Integer.class) == 1; - - if (!indexExists) - jdbcTemplate.execute("create index key_idx on cache_entry(key)"); + jdbcTemplate.execute("create index if not exists key_idx on cache_entry(key)"); } @Override