テーブルに180万個以上のレコードがある場合、このクエリが実行されるのがなぜ遅いのか分かりません。jdbcTemplate.query何百万ものレコードで低速実行中
public CustomerEmailFreq getFreqCodeByEmail(String email, String domain) {
CustomerEmailFreq customerEmailFreq = new CustomerEmailFreq();
Map namedParameters = new HashMap();
namedParameters.put("email", email);
namedParameters.put("domain", domain);
String sql = "select freq_cde,email_local,email_domain,last_src_date,last_src_time from ADDRESS where upper(email_local)=upper(:email) and upper(email_domain)=upper(:domain) ORDER BY TIMESTAMP(LAST_SRC_DATE,LAST_SRC_TIME) DESC FOR READ ONLY WITH UR FETCH FIRST ROW ONLY";
this.jdbcTemplate.query(sql, namedParameters, (rs, rowNum) ->
{
customerEmailFreq.setEmailDomain(rs.getString("EMAIL_DOMAIN").trim());
customerEmailFreq.setEmailLocal(rs.getString("EMAIL_LOCAL").trim());
customerEmailFreq.setFreqCode(rs.getString("FREQ_CDE"));
customerEmailFreq.setLastSrcDate(rs.getString("LAST_SRC_DATE"));
customerEmailFreq.setLastSrcTime(rs.getString("LAST_SRC_TIME"));
return null;
});
return customerEmailFreq;
}
これを助けるために任意のヒント。
dbで直接実行するとクエリにかかる時間はどのくらいですか? なぜあなたはnullを返していますか? –
4分以上かかる。ラムダ式を使用したので、nullを返す必要があります。 –
なぜあなたはそれが速く走ると思いますか? – mustaccio