我已经看过很多例子,但似乎没有一个能给我足够的帮助。
以下是我实施和工作的内容,但速度很慢:
方法1:
SELECT *
FROM
LogVisits T (NOLOCK)
WHERE
T.Msisdn = @TempMsisdn
ORDER BY
T.[VisitUrlCreatedDate], T.[VisitId] DESC
OFFSET @RecordStartIndex ROWS
FETCH NEXT (@RecordEndIndex - @RecordStartIndex) ROWS ONLY;
方法2:
SELECT
*
, (SELECT COUNT(*) FROM vLogVisit) AS [TotalRecordCount]
FROM
(
SELECT
ROW_NUMBER() OVER(ORDER BY T.[VisitUrlCreatedDate] DESC, T.[VisitId] DESC) AS IndexRank --, T.VisitUrlId DESC
, T.*
FROM
vLogVisit T
WHERE
T.Msisdn = @TempMsisdn
) AS VisitLogs
WHERE
IndexRank BETWEEN @RecordStartIndex AND @RecordEndIndex
ORDER BY
VisitUrlCreatedDate DESC
, VisitId DESC
我认为这两种方法首先采取和然后 获取我想要的部分。
由于 之前的数据计数超过100k,是否有更快的方式?