In my notebook, run the following sql code is (a total of approximately 70,000 rows of data lines, no index)
select * from(
SELECT nodeinfo.nodeID nodeid,nodeinfo.niid niid ,nodeinfo.type type ,nodeinfo.testType testtype,sensordatapacket.storedtime storedtime,sensordatapacket.value value,
sensordatapacket.unit unit,sensordatapacket.dataType datatype,nodeconfig.nodeAddress nodename
FROM
nodeinfo
Left Join sensordatapacket ON nodeinfo.nodeID = sensordatapacket.nodeID
Left Join nodeconfig ON nodeconfig.nodeID = nodeinfo.nodeID
where testtype='待测' and type='土壤温度' order by storedtime desc) a
group by a.nodeid order by a.storedtime desc
Red label portion, when used desc order by storedtime common 9.284s
Use order by storedtime asc time, when common 17.04s
Is not used in order by time 2.022s when sharing operation.
When the purpose of each nodeid, retrieved storedtime recent piece of data.
Without the use of order by the operation, data is retrieved, storedtime intermediate time of a certain time. Dr. EFCodd made in line with "a relation modal of data for large shared data banks" in
Theoretical relational model database. Physical storage database is not necessarily to the primary key is sequentially stored, the nature of the data in the table data is in a set.
Reproduced in: https: //www.cnblogs.com/zhangshufeng/archive/2012/09/28/2706859.html