简体   繁体   English

IIS 7,Microsoft Access和Classic ASP的最高效的ADODB连接

[英]Most efficient ADODB connection for IIS 7, Microsoft Access and Classic ASP

I'm managing an Intranet site written in Classic ASP, running in IIS7 on Windows Server 2008, and using Microsoft Access as a datastore (switching to a more capable database is not an option, nor is switching to .NET). 我正在管理一个用Classic ASP编写的Intranet站点,该站点在Windows Server 2008上的IIS7中运行,并且使用Microsoft Access作为数据存储(切换到功能更强大的数据库既不是一种选择,也不切换到.NET)。

Each page makes multiple calls to the datastore in order to populate various views, etc. 每个页面都会多次调用数据存储区,以填充各种视图等。

As traffic to the site has grown we are experiencing issues with page response times and one possible cause lies in the efficiency of the connections to the datastore. 随着网站访问量的增长,我们遇到了页面响应时间方面的问题,一个可能的原因在于与数据存储区的连接效率。

What is the most efficient ADO connection type to use for this type of setup? 对于这种类型的设置,最有效的ADO连接类型是什么?

We had a similar issue with a few of our websites. 我们的一些网站也有类似的问题。 All the content was database driven. 所有内容都是数据库驱动的。 We used SQL Server and made as few database round trips as possible when displaying web pages. 在显示网页时,我们使用SQL Server并进行了尽可能少的数据库往返。 We became concerned about heavy usage sites constantly hitting the database and made some changes to how our websites got built going forward. 我们开始关注频繁使用网站的频繁访问网站,并对网站的构建方式进行了一些更改。

We wound up replacing about 70% of the database driven content with static include files. 我们最终用静态包含文件替换了大约70%的数据库驱动内容。 We divided the website content data into three groups. 我们将网站内容数据分为三组。

  1. Static Content that did not change 不变的静态内容
  2. Semi-Static Content that changed rarely 半静态内容很少更改
  3. Database Driven Content 数据库驱动的内容

We replaced the Static Content with include files. 我们将静态内容替换为包含文件。 If the customer wanted a change, they told us, we made the change (for a fee). 如果客户要求更改,他们会告诉我们,我们进行了更改(收费)。

We classified the Semi-Static content as data that rarely changed but could be changed by the customer using the back-end interface . 我们将半静态内容分类为很少更改但可由客户使用后端接口更改的数据 In this case we also used static include files. 在这种情况下,我们还使用了静态包含文件。 After the changes to the database were made, we ran a (transparent to the user) static-data creation widget that recreated the static data as include files based on the database update. 在对数据库进行更改之后,我们运行了一个(对用户透明的)静态数据创建小部件,该小部件根据数据库更新将静态数据重新创建为包含文件。 The next time the page was called it would use the newly built include file. 下次调用该页面时,它将使用新建的包含文件。

I'm not sure you can gain performance from using different ADO types. 我不确定您可以通过使用不同的ADO类型来获得性能。 I think it's more to do with database size and structure. 我认为这与数据库的大小和结构有关。

I had similar troubles to you with my application. 我的申请给您带来了类似的麻烦。 Although I have built many, many apps for my clients, not many of them had a huge audience. 尽管我为我的客户构建了许多应用程序,但是其中有很多应用程序吸引了大量的用户。 Recently I have built one, and boy, did I have to learn a thing or two to get it to be efficient. 最近,我建造了一个,而男孩,我是否必须学习一两件事才能使它高效。

Here a few things to consider, if you haven't already. 如果您还没有考虑的话,这里有几件事情要考虑。 Some might be a bit basic for you but useful to others too: 有些对您来说可能有点基础,但对其他人也有用:

1) INDEX or FULLTEXT INDEX - To speed up my database, I added INDEX's to the columns I query which speeds up my queries a huge amount (but slows down the INSERT's slightly). 1) INDEX或FULLTEXT INDEX-为了加快数据库速度,我在查询的列中添加了INDEX,这大大加快了查询速度(但会稍微降低INSERT的速度)。 I also added FULLTEXT INDEX's to the columns where I searched for multiple words, so I could lose the horribly slow LIKE/IN clauses. 我还在搜索多个单词的列中添加了FULLTEXT INDEX,因此我可能会失去极其慢的LIKE / IN子句。

2) Normalization or De-normilization - One of my queries searched 16 tables using joins and sub-queries and turned out to be slow, bulky and confusing. 2) 规范化或反规范化 -我的一个查询使用联接和子查询搜索了16个表,结果发现它很慢,笨重且令人困惑。 I fixed this by creating a "de-normalized" table, that contained all the usable data from those 16 tables that I needed for the search. 我通过创建一个“非规范化”表来解决此问题,该表包含了搜索所需的那16个表中的所有可用数据。 So with the help of FULLTEXT INDEX and a de-normalized and indexed table, my query is just a few lines in length is remarkably quick. 因此,借助FULLTEXT INDEX和一个非规范化索引表,我的查询只有几行,速度非常快。 Before using de-normalized tables, you must first understand normalized tables. 在使用非规范化表之前,您必须首先了解规范化表。 For me, this was the correct situation where you can break the rules. 对我来说,这是可以违反规则的正确情况。

3) SQL Field selection - Only select the fields you require in your SQL query. 3) SQL字段选择 -仅选择SQL查询中所需的字段。 This is a simple mistake but still can be made. 这是一个简单的错误,但仍然可以犯。 For example, don't do (select * from myTable) if you don't need all the columns returned, do something more precise like (select id, fname from myTable), if that's the only columns you need. 例如,如果不需要所有返回的列,则不要执行(从myTable中选择*),如果这是唯一需要的列,请执行更精确的操作(从myTable中选择id,fname)。

4) DB cleanup - I'm not sure about Access but in MYSQL you can cleanup your DB by using the OPTIMIZE query, which repairs any gaps in your DB, sometimes created by inserting and deleting lots of data frequently. 4) 数据库清理 -我不确定Access,但是在MYSQL中,您可以使用OPTIMIZE查询来清理数据库,该查询可以修复数据库中的任何空白,有时是由于频繁插入和删除大量数据而造成的。 You can also use EXPLAIN, which explains your query in detail, such as a timer, indexes used, rows used and records returned. 您还可以使用EXPLAIN,它详细解释查询,例如计时器,使用的索引,使用的行和返回的记录。

There are many ways to gain DB performance. 有很多方法可以提高数据库性能。 If you Google "database optimization" or "database tuning", you should find some good reads.. 如果您使用Google“数据库优化”或“数据库优化”,则应该会读到一些不错的文章。

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

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