首页 文章

如何在MS Access中测试2种不同查询方法的速度?

提问于
浏览
1

我有一个链接到外部SQL Server表的数据库 . 我正在玩传递查询以尝试在服务器上运行查询并将结果返回到我的本地计算机 . 我被告知这对于有数千万行的表来说更快 . 但是,我希望能够向自己证明这比使用本地计算机查询要快 . 如何在MS Access中显示查询时间?或者,如果存在某种其他方式来查看哪个查询更快,我会全神贯注 .

My code for the pass-through query:

queryname = "qrypass_AbstrList_QuickInfo"
    Set qdf = CurrentDb.CreateQueryDef(queryname)
    qdf.Connect = "ODBC;DSN=Syteline;Description=Syteline;UID=userID;Trusted_Connection=Yes;DATABASE=ACW_App;LANGUAGE=us_english;"
    qdf.sql = "SELECT LTRIM(RTRIM(lp.lp_num)) as trim_lp, lot.item, lp.loc, lp.whse, lot.lot, lot.qty_on_hand " _
               & "FROM isw_lp As lp inner join isw_lplot as lot on lp.lp_num = lot.lp_num " _
               & "WHERE " & whereclause & ";"

    qdf.ReturnsRecords = True

    DoCmd.OpenReport "rpt_AbstrList_QuickInfo", acViewReport

3 回答

  • 0
    dim t as single
    t= timer
    'do something you want to measure'
    debug.print timer -t
    

    计时器不是很精确(返回秒数),但这对我来说通常已经足够了

  • 0

    选择查询之前的当前时间,并在查询之后再次选择 .

  • 1

    尝试使用它来测试时序差异

    Dim StartTime As Double
     Dim SecondsElapsed As Double
    
     StartTime = Timer
    

    并在[您正在测试的内容]结束时

    SecondsElapsed = Round(Timer - StartTime, 2)
     MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation
    

    这是我之前回答的复制/粘贴:DAO.Recordset performance

相关问题