[英]Statement.executeQuery taking same amount of time for every SQL query
[英]Statement.executeQuery() taking too much time. Is there any way to optimise this? I am using Athena DB
Statement.excecuteQuery()
花费太多时间,无论查询是什么。
athenaQuery = "SELECT DISTINCT date " +
"FROM sid.lvmh_shareofshelf_new_cat_all_dod "+
"where scope='PCD' and date!='' and country='" + countryName+ "' " +
"and rname='" + rname + "' and top_category_lvmh='" + top_category_lvmh +
"' ORDER BY date DESC";
stmt = conn.createStatement();
long startTime = System.nanoTime();
rs = stmt.executeQuery(athenaQuery);
long endTime = System.nanoTime();
System.out.println("Total time taken : "+ (endTime - startTime));
所用时间为 2776930359 纳秒(2.776930359 秒)
我不知道你的项目的内部结构。 我建议一些对你有帮助的事情。
比尝试看看是性能提高!
我检查了 Athena DB 驱动程序,
https://s3.amazonaws.com/athena-downloads/drivers/AthenaJDBC41-1.1.0.jar
它有 com.amazonaws.athena.jdbc.AthenaConnection 类,它实现了来自 JDBC API 的 java.sql.Connection 接口。 它具有JDBC承诺的所有prepareStatement重载方法。
我假设您已经知道使用 Prepared 语句的好处。
在您查询 Where 子句时,您的日期是 != '' 是字符数据类型吗?
你可以试试
日期不为空
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.