我试图确定表格中最早的记录,但结果却相互矛盾。
情景1
SELECT TOP 10 * FROM Ens_Util.Log ORDER BY TimeLogged ASC
SELECT TOP 10 text, TimeLogged, TraceCat, Type FROM Ens_Util.Log ORDER BY TimeLogged ASC
Text TimeLogged TraceCat Type
Email sent via mailserv:25 2016-05-08 01:00:01 (null) 4
[Requested record not found] 2016-05-08 01:01:13 (null) 2
[Requested record not found] 2016-05-08 01:04:39 (null) 2
[Requested record not found] 2016-05-08 01:04:53 (null) 2
[Requested record not found] 2016-05-08 01:05:22 (null) 2
[Requested record not found] 2016-05-08 01:05:45 (null) 2
[Requested record not found] 2016-05-08 01:05:58 (null) 2
[Requested record not found] 2016-05-08 01:05:58 (null) 2
[Requested record not found] 2016-05-08 01:06:08 (null) 2
[Requested record not found] 2016-05-08 01:06:15 (null) 2
情景2a
SELECT TOP 10 TimeLogged FROM Ens_Util.Log ORDER BY TimeLogged ASC
TimeLogged
2015-10-10 16:30:46
2015-10-10 21:15:07
2015-10-11 22:08:18
2015-10-12 21:57:00
2015-10-13 21:39:27
2015-10-14 23:40:15
2015-10-15 23:28:10
2015-10-16 23:36:52
2015-10-17 23:10:04
2015-10-18 22:32:49
情景2b
SELECT MIN(TimeLogged) FROM Ens_Util.Log
2015-10-10 16:30:46
问题
这里发生了什么?为什么会出现差异?最早的记录的日期是什么时候? 2016-05-08
或2015-10-10
?
答案 0 :(得分:5)
更多看起来您的索引不正确,而在不同的查询中使用不同的索引。只需调用这两个命令,清除所有索引,然后重新重建它,可能需要很长时间,具体取决于你有多少个日志。
do ##class(Ens.Util.Log).%PurgeIndices()
do ##class(Ens.Util.Log).%BuildIndices()
答案 1 :(得分:1)
我会尝试一些事情:
最糟糕的情况:
尝试按年份(TimeLogged),月份(TimeLogged),日期(TimeLogged),小时(TimeLogged),分钟(TimeLogged),秒(TimeLogged)
进行排序另外,以防万一:
尝试选择Year(TimeLogged),Month(TimeLogged),Day(TimeLogged),Hour(TimeLogged),Minute(TimeLogged),Second(TimeLogged) 查看是否可以从TimeLogged中提取正确的值