Microsoft Office
SharePoint Portal Server
MVP

Sign In

<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

RSS 2.0 | Atom 1.0 | CDF

Archive

Navigation

Search

Categories

On this page

MySQL和PostgreSQL的DAAB
Troubleshooting a Side-by-Side Installation of Reporting Services and Windows SharePoint Services
WSS3.0中文版发布!
配置MOSS2007beta2的单机开发环境(上)
[转]SQL Server一些常见性能问题的总结

京ICP备06027344号

Total Posts: 179
This Year: 1
This Month: 0
This Week: 0
Comments: 39

 Sunday, May 20, 2007
Sunday, May 20, 2007 12:10:34 AM (中国标准时间, UTC+08:00) ( )

最近在研究EntLib2.0的DAAB。DAAB的特性之一是可以使我们在编写代码的时候不必关心数据库到底是什么,也就是DAAB可以当作数据库抽象层。但是你得有你要使用的数据库在这个抽象层之下的驱动。

我们知道现在开源关系数据库主要有两个,一个是MySQL,一个是PostgreSQL。这两个数据库现在都有现成的开源.NET Data Provider。由于微软也提供了EntLib2.0的源代码,这样我们很容易仿照其SQL Server的DAAB Database Provider写出他们在抽象层之下的驱动。我试着写了一下,MySQL的部分实现了,PostgreSQL的完全没有实现。

MySQL的DAAB Database Provider除了XmlReader相关的部分,其他部分都实现了。这是由于MySQL的.net connecter虽然是仿照SQLServer的.NET Database Provider来定义的接口,但是.NET Framework 2.0新增的一些内容还没有实现,MySQL对于XML的支持也不如SQL Server那么完善。

PostgreSQL的DAAB Database Provider完全没有实现。和MySQL的.NET Database Provider类似,PostgreSQL的Npgsql也没实现XmlRaeder的功能,除此以外,Npgsql的NpgsqlCommand对象竟然没有继承DbCommand, ICloneable,导致在一些NpgsqlCommand强制转换的情景下会失败。这个情况导致了PostgreSQL的DAAB Database Provider没办法实现。

比较MySQL和PostgreSQL对.NET的支持,看来是MySQL更胜一筹。

为了解决使用Entlib的DAAB来访问PostgreSQL的问题,估计可能得写一个ODBC的DAAB Database Provider了。研究了一下ODBC的.NET Database Provider的情况,似乎ODBC和MySQL的情况类似,在.NET Framework2.0的类库里面并没有对XmlReader支持,估计仍然不能实现ODBC的DAAB Database Provider的XmlReader部分。

Comments [0] | | # 
 Thursday, November 30, 2006
Thursday, November 30, 2006 4:54:49 PM (中国标准时间, UTC+08:00) ( )

这篇文章来自ReportingService For SQL Server 2000的安装说明文件。

On Windows Server 2003, if you install Reporting Services with Windows SharePoint Services, you need to follow some basic steps in order for your system to function properly. To enable a side-by-side installation of Reporting Services and Windows SharePoint Services, perform the following steps.

  1. While installing Reporting Services, you may experience activation failures. Ignore any activation errors that occur.
  2. Add the Reporting Services virtual directories to the Windows SharePoint Services list of exclusions. If you installed Reporting Services using the default virtual directories, run the following at the command prompt:
    STSADM.EXE -o addpath -url http://localhost/ReportServer -type exclusion
    and
    STSADM.EXE -o addpath -url http://localhost/Reports -type exclusion
  3. Next, increase the trust level to full trust in the Report Server and Report Manager Web.config files. By default, the Report Server Web.config file is located at C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer. The Report Manager Web.config file is located at C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportManager. You can increase the trust level by modifying the trust level element of the system.web configuration element from <trust level="RosettaSRV" originURL=""/> and <trust level="RosettaMGR" originURL=""/> to the following:
    <trust level="Full" originUrl="" />
    You must make the trust level entry in both Web.config files. Modify only the trust level element of system.web. Do not modify the similarly named trustlevel element of the security policy configuration element.
  4. Add the following under the HttpModules configuration element of the SharePoint Web.config file if it does not already exist. By default, the SharePoint Web.config file is located at C:\Inetpub\wwwroot.
    <HttpModules>
       <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
    In addition to adding the session state module, you must also enable session state for the pages element by changing the enableSessionState attribute from false to true. The entry in the configuration files should look like the following:
    <pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" />
  5. From the Internet Information Services (IIS) Manager, ensure that the report server is in an application pool that is separate from the SharePoint server. The report server management user interface, Report Manager, can remain in the same application pool to which it was originally installed. To assign the report server to a separate application pool, you must first create a new application pool. After you have created a new application pool, expand Web Sites, expand Default Web Site, right-click the report server virtual root that you created during setup (the default is ReportServer), and then click Properties. From the Application pool drop down, select the newly-created application pool. For more information about application pools, see your Internet Information Services documentation.
  6. Finally, use the rsactivate utility to activate the local instance of Reporting Services. You need to install Administrative Tools and Utilities as part of Reporting Services setup in order to use the rsactivate utility. By default, rsactivate is located at C:\Program Files\Microsoft SQL Server\80\Tools\Binn. If you installed your report server to the default location, run the following at the command prompt:
    rsactivate -c "C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\RSReportServer.config"
Comments [0] | | # 
 Saturday, November 18, 2006
Saturday, November 18, 2006 11:54:17 AM (中国标准时间, UTC+08:00) (  |  |  |  )

WSS3.0Start.jpg

今天上午WSS3.0提供下载了,中文版也一同发布了。正好手头有一个.NET Framework 3.0的虚拟机,立刻就把这个东西装上了。感觉不错。安装过程很顺畅,没有BETA2时候安装不长的问题了。安装过程和MOSS2007 BETA2的安装过程很像,但是缺一些东西,估计这些就是区别。

现在发现的和MOSS2007的区别是MOSS2007独立模式安装的时候,会安装一个SQL Server 2005的Express版的引擎,这个引擎可以通过标准的SQL Server 2005的管理工作室进行管理。而WSS3.0独立模式安装的时候,数据库引擎是一个SQL Server 2005的嵌入版。在使用SQL Server 2005的管理工作室的实例列表当中可以看到他创建的实例,但是不能连接,提示“引擎不提供远程连接功能”。估计这就是SQL Server 2005的Express版和嵌入版的区别所在,还有就是嵌入版默认的安装位置是%windir%\SYSMSI目录。我是第一次知道有这样一个SQL Server 2005的版本存在,需要研究一下这个版本的特性。

WSS3.0的内存消耗堪称一流,我的机器上除了企业版的SQL Server 2005以外,就是这个WSS3.0和其附带的嵌入版的SQL Server 2005了,这个时候内存占用达到了850兆。不知道MS怎么想的,这个内存的消耗是在太大了,虽然现在内存便宜,工作组服务器也不贵,但是这样的内存消耗也太大了点...在虚拟机里面有点实在吃不消了。

在前两天随.NET Framework 3.0一起发布的VS.NET 2005的WSS3.0扩展是个很不错的东西,除了带有Webpart模板意外,还能创建站点定义。这个可以看看陈曦的blog里面的描述

前面一段时间我的blog里面的文章少了,但是随着.NET Framework 3.0和MOSS2007的到来,各样的文章会如潮涌一样上来的...敬请关注

Comments [0] | | # 
 Monday, September 18, 2006
Monday, September 18, 2006 3:37:30 PM (中国标准时间, UTC+08:00) (  |  |  |  |  |  )

准备分两次介绍MOSS2007beta2单机开发环境的创建,第一部分主要是基本的创建过程,第二部分是主要是由beta2升级到Beta2TechRefresh的过程。

看我Blog的人,大约都已经看了kaneboy和ocean的介绍了,但是我还是要说说我创建MOSS2007beta2开发环境的创建,主要我觉得他们的写的过程,我觉得并没有把所有的事情都讲清楚。我的文档是根据英文的Deployment Guide for Office SharePoint Server(Office SharePoint Server部署指南,简称MOSS部署指南)实践后编写的,但不是单纯的翻译。我假设我的读者熟悉Win2003的管理和熟悉ASP.NET2.0的开发,这样我可以把MOSS部署指南当中叙述很详细的过程描述简化。

  1. 下载需要的文件。除了需要MOSSbeta2的安装部件以外,如果单机开发环境还要做域控制器的话,那么还要下载一个补丁。这个补丁需要在MOSS安装完毕,配置向导运行成功以后执行。可以修正在域控制器上安装单机环境浏览报错的问题。
  2. 我们可以准备一个VirtualPC或者一个真实的PC。这个PC要安装好Win2003的任何一个版本,为其安装配置好AD、DNS、应用服务器(启用ASP.NET)三个角色。然后打补丁SP1。接着我们需要安装.NET Framework 2.0 运行时部件和Windows Workflow Foundation 2.2(简称WWF)运行时部件。
  3. 接下来我们开始安装MOSS。在添加完序列号以后,系统会提示我们用Basic还是Advanced方式安装。Basic是默认使用Stand方式安装,默认C盘为安装路径,同时在配置向导运行时,还将默认创建一个的MOSS网站和相应的Web Application。Advanced则全部需要自己手动设置。我们这里选择Basic。后面只需要逐步点Next就可以将MOSS安装完毕。安装完毕以后,可以根据需要安装对于域控制器做MOSS服务器的补丁
    注意:我们没有安装SQLServer2005,这是因为MOSS的安装程序在Basic模式下会自动安装一个SQLEXPRESS,并默认一次数据库作存储。
  4. 在测试以后,我们可以开始Office2007beta2和VS2005安装开发环境了。安装Office2007beta2就不详细介绍了。然后我们可以选择任何一个VS2005的版本,除了VS2005Express的版本以外。安装的时候我们可以只选择VS2005的最小版本,比如只安装最小的VistualC#.Net环境。接下来可以安装WWF的VS2005设计组件。这时一个基本的MOSS2007beta2的单机开发环境就已经做好了。

使用Basic模式虽然可控性比较差,但是我们可以通过这个快速的建立MOSS2007beta2的开发环境。此外这个环境大约需要1.5GB的内存,如果不需要开发环境大约1GB内存就足够了。如果要在VisualPC当中做的话,则宿主需要至少2GB以上的内存。

Comments [0] | | # 
 Thursday, June 29, 2006
Thursday, June 29, 2006 8:19:47 PM (中国标准时间, UTC+08:00) ( )

1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。

2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:
select id from t where num is null
可以在num上设置默认值0,确保表中num列没有null值,然后这样查询:
select id from t where num=0

3.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描。

4.应尽量避免在 where 子句中使用 or 来连接条件,否则将导致引擎放弃使用索引而进行全表扫描,如:
select id from t where num=10 or num=20
可以这样查询:
select id from t where num=10
union all
select id from t where num=20

5.in 和 not in 也要慎用,否则会导致全表扫描,如:
select id from t where num in(1,2,3)
对于连续的数值,能用 between 就不要用 in 了:
select id from t where num between 1 and 3

6.下面的查询也将导致全表扫描:
select id from t where name like '%abc%'
若要提高效率,可以考虑全文检索。

7.如果在 where 子句中使用参数,也会导致全表扫描。因为SQL只有在运行时才会解析局部变量,但优化程序不能将访问计划的选择推迟到运行时;它必须在编译时进行选择。然而,如果在编译时建立访问计划,变量的值还是未知的,因而无法作为索引选择的输入项。如下面语句将进行全表扫描:
select id from t where num=@num
可以改为强制查询使用索引:
select id from t with(index(索引名)) where num=@num

8.应尽量避免在 where 子句中对字段进行表达式操作,这将导致引擎放弃使用索引而进行全表扫描。如:
select id from t where num/2=100
应改为:
select id from t where num=100*2

9.应尽量避免在where子句中对字段进行函数操作,这将导致引擎放弃使用索引而进行全表扫描。如:
select id from t where substring(name,1,3)='abc'--name以abc开头的id
select id from t where datediff(day,createdate,'2005-11-30')=0--‘2005-11-30’生成的id
应改为:
select id from t where name like 'abc%'
select id from t where createdate>='2005-11-30' and createdate<'2005-12-1'

10.不要在 where 子句中的“=”左边进行函数、算术运算或其他表达式运算,否则系统将可能无法正确使用索引。

11.在使用索引字段作为条件时,如果该索引是复合索引,那么必须使用到该索引中的第一个字段作为条件时才能保证系统使用该索引,否则该索引将不会被使用,并且应尽可能的让字段顺序与索引顺序相一致。

12.不要写一些没有意义的查询,如需要生成一个空表结构:
select col1,col2 into #t from t where 1=0
这类代码不会返回任何结果集,但是会消耗系统资源的,应改成这样:
create table #t(...)

13.很多时候用 exists 代替 in 是一个好的选择:
select num from a where num in(select num from b)
用下面的语句替换:
select num from a where exists(select 1 from b where num=a.num)

14.并不是所有索引对查询都有效,SQL是根据表中数据来进行查询优化的,当索引列有大量数据重复时,SQL查询可能不会去利用索引,如一表中有字段sex,male、female几乎各一半,那么即使在sex上建了索引也对查询效率起不了作用。

15.索引并不是越多越好,索引固然可以提高相应的 select 的效率,但同时也降低了 insert 及 update 的效率,因为 insert 或 update 时有可能会重建索引,所以怎样建索引需要慎重考虑,视具体情况而定。一个表的索引数最好不要超过6个,若太多则应考虑一些不常使用到的列上建的索引是否有必要。

16.应尽可能的避免更新 clustered 索引数据列,因为 clustered 索引数据列的顺序就是表记录的物理存储顺序,一旦该列值改变将导致整个表记录的顺序的调整,会耗费相当大的资源。若应用系统需要频繁更新 clustered 索引数据列,那么需要考虑是否应将该索引建为 clustered 索引。

17.尽量使用数字型字段,若只含数值信息的字段尽量不要设计为字符型,这会降低查询和连接的性能,并会增加存储开销。这是因为引擎在处理查询和连接时会逐个比较字符串中每一个字符,而对于数字型而言只需要比较一次就够了。

18.尽可能的使用 varchar/nvarchar 代替 char/nchar ,因为首先变长字段存储空间小,可以节省存储空间,其次对于查询来说,在一个相对较小的字段内搜索效率显然要高些。

19.任何地方都不要使用 select * from t ,用具体的字段列表代替“*”,不要返回用不到的任何字段。

20.尽量使用表变量来代替临时表。如果表变量包含大量数据,请注意索引非常有限(只有主键索引)。

21.避免频繁创建和删除临时表,以减少系统表资源的消耗。

22.临时表并不是不可使用,适当地使用它们可以使某些例程更有效,例如,当需要重复引用大型表或常用表中的某个数据集时。但是,对于一次性事件,最好使用导出表。

23.在新建临时表时,如果一次性插入数据量很大,那么可以使用 select into 代替 create table,避免造成大量 log ,以提高速度;如果数据量不大,为了缓和系统表的资源,应先create table,然后insert。

24.如果使用到了临时表,在存储过程的最后务必将所有的临时表显式删除,先 truncate table ,然后 drop table ,这样可以避免系统表的较长时间锁定。

25.尽量避免使用游标,因为游标的效率较差,如果游标操作的数据超过1万行,那么就应该考虑改写。

26.使用基于游标的方法或临时表方法之前,应先寻找基于集的解决方案来解决问题,基于集的方法通常更有效。

27.与临时表一样,游标并不是不可使用。对小型数据集使用 FAST_FORWARD 游标通常要优于其他逐行处理方法,尤其是在必须引用几个表才能获得所需的数据时。在结果集中包括“合计”的例程通常要比使用游标执行的速度快。如果开发时间允许,基于游标的方法和基于集的方法都可以尝试一下,看哪一种方法的效果更好。

28.在所有的存储过程和触发器的开始处设置 SET NOCOUNT ON ,在结束时设置 SET NOCOUNT OFF 。无需在执行存储过程和触发器的每个语句后向客户端发送 DONE_IN_PROC 消息。

29.尽量避免大事务操作,提高系统并发能力。

30.尽量避免向客户端返回大数据量,若数据量过大,应该考虑相应需求是否合理。

具体的SQL语句在很多情况下需要结合实际的应用情况来写,这里不作叙述。

Comments [0] | | #