简体   繁体   English

访问链接后端表打开第一个表很慢,然后在创建记录锁定文件后很快 - 我可以保持这个锁定文件打开吗?

[英]Access linked Backend tables is slow to open for 1st table, then fast once record-locking file is created - can I keep this lock file open?

I have been working successfully so far with a database that has a split backend.到目前为止,我一直在使用具有拆分后端的数据库成功工作。 During development the front and backends have been in the same drive, but now the backend is on a.network drive in preparation for multiple users.在开发过程中,前后端一直在同一个驱动器中,但现在后端在一个.network 驱动器上,为多个用户做准备。

My issue is that whenever I now open a linked table (or form that reads data from it) from the frontend, the first table is always slow to load.我的问题是,每当我现在从前端打开链接表(或从中读取数据的表单)时,第一个表的加载速度总是很慢。 And if I then close that table and open another table, that's also slow to to load.如果我然后关闭该表并打开另一个表,加载速度也会很慢。 But if I open any table and then open a second table, the second table and any others thereafter is fast.但是如果我打开任何一张桌子然后打开第二张桌子,那么第二张桌子和之后的任何其他桌子都会很快。

It seems it may be that it's related to the locking file having to be created, and then closing when the table closes, meaning there's a delay when that file has to be created again for the next table.看起来它可能与必须创建锁定文件有关,然后在表关闭时关闭,这意味着必须为下一个表再次创建该文件时会有延迟。

Is there way to create the record-locking file on application launch so that it remains available throughout a user's session?有没有办法在应用程序启动时创建记录锁定文件,以便它在整个用户的 session 中保持可用?

Thank you谢谢

Yes, this is a wide known problem and for years we suggest you adopt what is called a persistent connection.是的,这是一个广为人知的问题,多年来我们建议您采用所谓的持久连接。

If you are doing development, then often what one can do is simple click on a table (any linked table) to open it, now you can work, design forms, and not experience huge delays during the development process.如果你在做开发,那么通常你可以做的就是简单地点击一个表(任何链接表)打开它,现在你可以工作,设计 forms,并且在开发过程中不会遇到巨大的延迟。

While the above fixes the delays during and when developing, the SAME concept and approach can be used for when you run your application.虽然上面修复了开发期间和开发时的延迟,但在运行应用程序时可以使用相同的概念和方法。

Like every applcation, you no doubt have some startup code.像每个应用程序一样,您无疑有一些启动代码。 This code can go in the first form that you launch on applcation startup.此代码可以 go 在您在应用程序启动时启动的第一个表单中。

So, you can create a standard code module.因此,您可以创建标准代码模块。 Say it is Module1.假设它是 Module1。 In that module, you can place this code:在该模块中,您可以放置以下代码:

  Option Compare Database
  Option Explicit
  
  Public rstPersist    As DAO.Recordset
  
  
  Sub MyOpenPersist()
  
      ' opens a back end table to force and keep
      ' open the connection for greatly improved
      ' speed
      
      Set rstPersist = CurrentDb.OpenRecordset("tblDefaults")
  
  End Sub

And then in the FIRST form you launch on startup, in the on-load even, you can include this code:然后在启动时启动的 FIRST 表单中,甚至在加载时,您可以包含以下代码:

 Call MyOpenPersist

Now, this will open a table to a "global" rstPersit recordset.现在,这将为“全局”rstPersit 记录集打开一个表。

Now, and from that point on-wards, since the locking file has been created (which takes a long time as you note), then the applcation, forms, and everything will now run without that delay.现在,从那时起,由于已创建锁定文件(如您所见,这需要很长时间),因此应用程序 forms 和所有内容现在都将运行而不会出现延迟。

It does not matter which table you choose to open - only requirement is that the table is a linked table, since you can (and might) have some local tables in the front end for things like settings or whatever.您选择打开哪个表并不重要——唯一的要求是该表是一个链接表,因为您可以(并且可能)在前端有一些本地表,用于设置或其他内容。 So, in this case, I open up a table called defaults (and it great to have that table open, since it is a 1 record table with default things like City and default area code for phone numbers etc.).因此,在本例中,我打开了一个名为 defaults 的表(打开该表非常好,因为它是一个 1 条记录的表,其中包含默认的内容,例如城市和电话号码的默认区号等)。 So, I in effect kill two birds with one stone so to speak, since I need a table of defaults for many things in the applcation anyway.所以,可以这么说,我实际上用一块石头杀死了两只鸟,因为无论如何我都需要一个默认表来处理应用程序中的许多事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM