I have a requirement to check all records in a table which is big (Around 1.5-2 million records). What I am doing is very simple, just get all the records and loop through one by one, and do things. I have a quartz job which will run every 2 minutes to check things.ApplicationDetailCheckingJob.javapublic class ApplicationDetailCheckingJob implements Job {@Autowiredprivate DatabaseService databaseService;@Value(${EnableJob})private boolean enableJob;@Overridepublic void execute(JobExecutionContext jobExecutionContext) {    if (enableJob) {        try {            LogService.info(this.getClass().getName(), Started Checking...);            //Get All Records            List<Applications> allApplicationDetails = databaseService.getAllAppDetails();                //Perform Check For Each Application                allApplicationDetails.stream().forEachOrdered((app) -> {                    //Check For Columns Values                    //If SendTweet = 1, Send tweet to the Application's User                    //If SendEmail = 1, Send Email to User                    //If Send SMS = 1, Send SMS to User                    //Rest is also similar procedures                });            LogService.info(this.getClass().getName(), Finished checking.);        } catch (Exception e) {            LogService.error(this.getClass().getName(), e);        }    } else {        LogService.info(this.getClass().getName(), ApplicationDetailChecking Job is Disabled);    } }}DatabaseService.javapublic List<Applications> getAllAppDetails() {    String sqlQuery = SELECT * FROM Applications;    List<Applications> appDetails = defaultJdbcTemplate.query(sqlQuery, BeanPropertyRowMapper.newInstance(Applications.class));    LogService.info(this.getClass().getName(), Number of records found =  + appDetails.size());    return appDetails;}Can I improve these methods? Is there a better way?If I use it in the live DB, I doubt the job can be finished before it's started again after 2 mins.
Job execution on records supplied by database
java;sql server;spring