Skip to content

Commit 34125b7

Browse files
committed
Improve SQL
1 parent efa1fb8 commit 34125b7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

frameworks/Kotlin/hexagon/store_pgclient/src/main/kotlin/BenchmarkPgClientStore.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class BenchmarkPgClientStore(
1919
) : BenchmarkStore(settings) {
2020

2121
companion object {
22-
private const val SELECT_WORLD: String = "select * from world where id = $1"
22+
private const val LOAD_WORLDS: String = "select id, randomNumber from world"
23+
private const val SELECT_WORLD: String = "select id, randomNumber from world where id = $1"
2324
private const val UPDATE_WORLD: String = "update world set randomNumber = $1 where id = $2"
24-
private const val SELECT_ALL_FORTUNES: String = "select * from fortune"
25+
private const val SELECT_ALL_FORTUNES: String = "select id, message from fortune"
2526
}
2627

2728
private val connectOptions: PgConnectOptions by lazy {
@@ -81,13 +82,12 @@ class BenchmarkPgClientStore(
8182
.toCompletionStage()
8283
.toCompletableFuture()
8384
.get()
84-
8585
}
8686
}
8787

8888
override fun initWorldsCache(cache: Cache<Int, CachedWorld>) {
8989
dataSource
90-
.preparedQuery("select * from world")
90+
.preparedQuery(LOAD_WORLDS)
9191
.execute()
9292
.map { rowSet ->
9393
rowSet.map { row ->

frameworks/Kotlin/hexagon/store_sql/src/main/kotlin/BenchmarkSqlStore.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ class BenchmarkSqlStore(
1616
) : BenchmarkStore(settings) {
1717

1818
companion object {
19-
private const val SELECT_WORLD: String = "select * from world where id = ?"
19+
private const val LOAD_WORLDS: String = "select id, randomNumber from world"
20+
private const val SELECT_WORLD: String = "select id, randomNumber from world where id = ?"
2021
private const val UPDATE_WORLD: String = "update world set randomNumber = ? where id = ?"
21-
private const val SELECT_ALL_FORTUNES: String = "select * from fortune"
22+
private const val SELECT_ALL_FORTUNES: String = "select id, message from fortune"
2223
}
2324

2425
private val dataSource: HikariDataSource by lazy {
@@ -87,7 +88,7 @@ class BenchmarkSqlStore(
8788

8889
override fun initWorldsCache(cache: Cache<Int, CachedWorld>) {
8990
dataSource.connection.use { con: Connection ->
90-
val stmtSelect = con.prepareStatement("select * from world")
91+
val stmtSelect = con.prepareStatement(LOAD_WORLDS)
9192
val rs = stmtSelect.executeQuery()
9293

9394
while (rs.next()) {

0 commit comments

Comments
 (0)