实验环境
操作系统:Windows 10
RAM:16.0 GB
处理器:Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz 1.99 GHz
实验配置
有1个device,device有100个tensor,每一个tensor有100000000条timeseries。其中,s0与每条数据timestamp相同,s1中的数据以10万条为一循环,每个循环中包含1万1...1万条10。
实验场景
数据分布
集中分布
查询结果全部在某一时间段内,连续没有间隔,如下图所示
-----****-----
均匀分布
查询结果均匀分布在一亿条timeseries中,如下图所示
--*--*--*--*--
数据选择率
选择率为查询结果的数据量占总数据量的比值。在实验中,在选择率为0%,1%,10%,50%,100%的场景下进行了测试。
查询种类
共进行三种查询:带值过滤的原始数据查询;带值过滤的聚合查询(Count和Max_Value两种),带值过滤的group by查询(Count和Max_Value两种+10-1000不同粒度)
以在集种分布下选择率为0的查询为例:
select s0 from root.sg1.d1 where s0<0
select s0 from root.sg1.d1 where s0<0
select max_value(s0) from root.sg1.d1 where s0<0
select count(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 10ms)
select max_value(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 10ms)
select count(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 100ms)
select max_value(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 100ms)
select count(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 1000ms)
select max_value(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 1000ms)
实验结果
如上表所示,可以发现,在进行原始数据查询和聚合查询时,当选择率较低的场景下,查询执行时间有明显的提升,选择率大于50%以后与原有时间持平。
实验代码
import org.apache.iotdb.jdbc.IoTDBSQLException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class JDBCQuery { public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("org.apache.iotdb.jdbc.IoTDBDriver"); try (Connection connection = DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); Statement statement = connection.createStatement()) { String sql = "select s0 from root.sg1.d1 where s0<0"; System.out.println(sql); long startTime=System.currentTimeMillis(); ResultSet resultSet = statement.executeQuery(sql); outputResult(resultSet); long endTime=System.currentTimeMillis(); System.out.println("time: "+(endTime-startTime)+"ms"); } catch (IoTDBSQLException e) { System.out.println(e.getMessage()); } } private static void outputResult(ResultSet resultSet) throws SQLException { if (resultSet != null) { System.out.println("--------------------------"); System.out.println(); while (resultSet.next()) { } } System.out.println("--------------------------\n"); } }