I have a very simple query that takes 70 seconds when running through a very simple bare bones Spring Boot app using a direct JDBC connection, but when run directly on Oracle SQL Developer, it only takes 13 seconds. There are 7000 records in the table if that makes a difference.
The query is that I run from SQL Developer is very simple.
select id from task
I hit Ctrl+End when in SQL Developer to get all rows in the table, there are 7000 records returned.
My slower Java code consists of a Dao using Spring JDBC template.
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String GET_ALL_TASKS = "SELECT id FROM task";
public List<Task> getAllTasks() {
RowMapper<Task> rm = new TaskRowMapper();
return this.jdbcTemplate.query(GET_ALL_TASKS, rm);
}
I have this POJO.
@Data
@AllArgsConstructor
public class Task {
private Bigdecimal id;
}
And I have a controller that just calls the Dao.
@RestController
public class TestController {
@Autowired
private TaskDao taskDao;
@RequestMapping("/")
public void test() {
taskDao.getAllTasks();
}
My TaskRowMapper class is empty and doesn't do anything as I was concerned maybe it was the cause of the slow performance.
With virtually no processing at all on the Java side, I am very confused as to how Java can run the query over 5x slower.
Has anyone got any suggestions, or is it a case that I have an unreasonable expectation to hope that my bare bones Java app should be able to run an Oracle query in only a second or two more than it takes to run on Oracle directly?