提高ACCESS的更新性能

时间:2016-09-07 14:02:55

标签: sql ms-access sql-update database-performance

我在Access中有2个表:

tbl_RM: (+ for primary key)
  + CustomerName (short text)
  + CountryCode  (short text)
  + RMDate       (Date/Time - format mmm-yy)
  + SerialNumber (short text)
    BlackClicks  (Double)
    ColorClicks  (Double)
    AccentClicks (Double)
    ProfessionalColorClicks (Double)

第二张表

tbl_Invoices: (+ for primary key)
  + CustomerName (short text)
  + CountryCode  (short text)
  + InvoiceDate  (Date/Time)
  + SerialNumber (short text)
    BlackClicks  (Double)
    ColorClicks  (Double)

tbl_RM包含98 496条记录(其中9113条符合以下查询)

tbl_Invoices包含9 618条记录(均符合以下请求)。

我想用来自tbl_RM的数据更新tbl_Invoices。这是我的更新查询:

UPDATE tbl_Invoices
INNER JOIN tbl_RM 
      ON tbl_Invoices.CustomerName = tbl_RM.CustomerName
      AND tbl_Invoices.CountryCode = tbl_RM.CountryCode
      AND tbl_Invoices.SerialNumber = tbl_RM.SerialNumber
      AND MONTH(tbl_RM.RMDate) = MONTH(tbl_Invoices.InvoiceDate)
      AND YEAR(tbl_RM.RMDate) = YEAR(tbl_Invoices.InvoiceDate)
SET tbl_Invoices.BlackPages =  tbl_RM.BlackClicks + tbl_RM.AccentClicks,
tbl_Invoices.ColorPages =  tbl_RM.ColorClicks + tbl_RM.ProfessionalColorClicks

在ACCESS 2013中运行此功能时,计算需要数小时。我想有办法加快速度。任何建议都将非常受欢迎。

1 个答案:

答案 0 :(得分:1)

第一个建议是tbl_RM(CustomerName, CountryCode SerialNumber)的索引。可能还不错。如果不是那么你也可能需要处理索引中的日期。