3.0.4.0版本,tdengine查询结果错误,相同的sql,查询count和查询数据,返回的数据不一致
一、预置条件 1.创建表 create table test(ts timestamp, oid int, fevalue int);
2.插入数据 insert into test values(1729166111443340001,1,1), (1729166111443340002,1,2), (1729166111443340003,1,3), (1729166111443340004,1,4), (1729166111443340005,1,5), (1729166111443340006,1,6), (1729166111443340007,1,7), (1729166111443340008,1,8), (1729166111443340009,1,9), (1729166111443340010,1,10), (1729166111443340011,1,11), (1729166111443340012,1,12), (1729166111443340013,1,13), (1729166111443340014,1,14), (1729166111443340015,1,15);
二、非主键列 1.这里用oid(非主键列)来做范围限定,没有问题 taos> select count() from (select * from test order by oid asc limit 5) limit 10; count() 5
2.这里用oid(非主键列)来做范围限定,没有问题
select * from (select * from test order by oid asc limit 5) limit 10;
ts | oid | fevalue |
2024-10-17 19:55:11.443340001 | 1 | 1 |
2024-10-17 19:55:11.443340014 | 1 | 14 |
2024-10-17 19:55:11.443340002 | 1 | 2 |
2024-10-17 19:55:11.443340003 | 1 | 3 |
2024-10-17 19:55:11.443340004 | 1 | 4 |
Query OK, 5 row(s) in set (0.023000s)
三、主键列 1.用主键列来做范围限定,查询总数没有问题: taos> select count() from (select * from test order by ts asc limit 5) limit 10; count() 5
2.这里用ts(非主键列)来做范围限定,有问题:
taos> select * from (select * from test order by ts asc limit 5) limit 10;
ts | oid | fevalue |
2024-10-17 19:55:11.443340001 | 1 | 1 |
2024-10-17 19:55:11.443340002 | 1 | 2 |
2024-10-17 19:55:11.443340003 | 1 | 3 |
2024-10-17 19:55:11.443340004 | 1 | 4 |
2024-10-17 19:55:11.443340005 | 1 | 5 |
2024-10-17 19:55:11.443340006 | 1 | 6 |
2024-10-17 19:55:11.443340007 | 1 | 7 |
2024-10-17 19:55:11.443340008 | 1 | 8 |
2024-10-17 19:55:11.443340009 | 1 | 9 |
2024-10-17 19:55:11.443340010 | 1 | 10 |
Query OK, 10 row(s) in set (0.032002s)