sqlserver 里面top语句会影响到数据库查询速度

具体什么原因不太清楚,有个写法大家参考一下

 RANK() OVER (ORDER BY st.study_uid_id) AS rnk
SELECT 文档Id
FROM (
    SELECT '1.2.3.4.' + st.study_uid AS 文档Id, RANK() OVER (ORDER BY st.study_uid_id) AS rnk
    FROM dbo.patient1 A (NOLOCK)
    INNER JOIN dbo.study1 st ON ST.ptn_id_id = a.ptn_id_id
    INNER JOIN  dbo.ris_request b ON st.accession_number = b.accession_number
    INNER JOIN  dbo.ris_patient c ON b.patientid = c.patientid
    WHERE st.STUDY_TIME IS NOT NULL
      AND b.stateid = '60'
      AND st.study_uid_id >= (SELECT MAX(study_uid_id) FROM datax_status_time)
) AS sub
WHERE rnk <= 10;

你可能感兴趣的:(数据库,sqlserver)