I have a table of 10 million records with 25 fields in it. I have used Apache Ignite’s SQL driver to store the table in the cache. To retrieve them I’m using the same to query those data. But it’s much slower than retrieving from key-value. Why?
This is my implementation of fetching the data from ignite server:
public List<Map<String, Object>> getData(@RequestBody String query) throws ClassNotFoundException {
List<Map<String, Object>> resultList = new ArrayList<>();
try (Connection igniteConn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
SqlFieldsQuery sqlFieldsQuery = new SqlFieldsQuery(query).setLocal(false).setPageSize(100);
try (PreparedStatement selectStmt = igniteConn.prepareStatement(sqlFieldsQuery.getSql())) {
try (ResultSet resultSet = selectStmt.executeQuery()) {
ResultSetMetaData metaData = resultSet.getMetaData();
int columns = metaData.getColumnCount();
boolean foundData = false;
while (resultSet.next()) {
foundData = true;
Map<String, Object> row = new LinkedHashMap<>();
for (int i = 1; i <= columns; i++) {
String columnName = metaData.getColumnName(i);
Object value = resultSet.getObject(i);
row.put(columnName, value);
}
resultList.add(row);
}
if (!foundData) {
Map<String, Object> emptyResult = new LinkedHashMap<>();
emptyResult.put("message", "No data found");
resultList.add(emptyResult);
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return resultList;
}