2016-06-07 73 views
1

我試圖確定表中最舊的記錄,並且結果有衝突。最舊記錄差異?

方案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-082015-10-10

+1

我會重新索引並重建統計數據,然後再次嘗試 – Peter4499

回答

4

看起來像您的索引看起來不正確,而在不同的查詢中使用不同指數。只需調用這兩個命令,清除所有索引,然後重新構建它,這可能需要很長時間,具體取決於您擁有多少個日誌。

do ##class(Ens.Util.Log).%PurgeIndices() 
do ##class(Ens.Util.Log).%BuildIndices() 
+0

不幸的是我沒有能力做到這一點,但我已經把我們的主機的請求。我會更新結果。 –

+0

如果您有訪問權限,可以嘗試通過[System Portal management](http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_persother#GOBJ_persother_rls_existrbld) – DAiMor

+0

幾乎零訪問LIVE,謝謝:) –

0

有幾件事情我會嘗試:

  • 檢查了TimeLogged確實是一個DATATIME場
  • 嘗試強制轉換爲字符串和排序(有時隱式轉換混淆排序)
  • 嘗試鑄成日期

最壞的情況:

嘗試年份(TimeLogged),蒙訂購H(TimeLogged),日(TimeLogged),小時(TimeLogged),分(TimeLogged),二(TimeLogged)

也,以防萬一:

儘量選擇年份(TimeLogged),月(TimeLogged) ,Time(TimeLogged),Hour(TimeLogged),Minute(TimeLogged),Second(TimeLogged) 以查看是否可以從TimeLogged中提取正確的值