1.你表单提交里面使用的语句是否有问题,
或者说是出现了什么异常没有,
如果我将IIS 和 MS-SQL 分两个服务器装。
2.基于安全或者分布式系统的考虑,尽量分开好一些, 
  这样应用服务器(也就是你IIS的服务器)不至于和数据库服务器(也就是你的SQL数据库)竞争资源,
  而且这种分布式的部署方式,如果你其中一台服务器出现异常,
  可以很快地使用另外一台备用的服务器来替换,如果是都在一个服务器上的话,
  那么这个就比较困难了,

解决方案 »

  1.   


    用事件查看器。监视到的语句。 
     
     
     select 504,c.name,c.description,c.definition from master.dbo.syscharsets c where c.id = convert(tinyint, databasepropertyex ( db_name() , 'sqlcharset'))
    go
    declare @P1 int
    set @P1=180150000
    declare @P2 int
    set @P2=8
    declare @P3 int
    set @P3=1
    declare @P4 int
    set @P4=1
    exec sp_cursoropen @P1 output, N'SELECT top 1 * FROM tbconfig', @P2 output, @P3 output, @P4 output
    select @P1, @P2, @P3, @P4
    go
    exec sp_cursorfetch 180150000, 16, 1, 1
    go
    declare @P1 int
    set @P1=1
    declare @P2 int
    set @P2=1
    exec sp_cursorfetch 180150000, 256, @P1 output, @P2 output
    select @P1, @P2
    go
    declare @P1 int
    set @P1=180150001
    declare @P2 int
    set @P2=1
    declare @P3 int
    set @P3=2
    declare @P4 int
    set @P4=1
    exec sp_cursoropen @P1 output, N'SELECT  * from tbscore  where username=''20080023''   and paperno=17', @P2 output, @P3 output, @P4 output
    select @P1, @P2, @P3, @P4
    go
    exec sp_cursorfetch 180150001, 16, 1, 1
    go
    declare @P1 int
    set @P1=1
    declare @P2 int
    set @P2=1
    exec sp_cursorfetch 180150001, 256, @P1 output, @P2 output
    select @P1, @P2
    go
    declare @P1 int
    set @P1=180150002
    declare @P2 int
    set @P2=1
    declare @P3 int
    set @P3=2
    declare @P4 int
    set @P4=1
    exec sp_cursoropen @P1 output, N'SELECT * from tbpaper  where   paperno=17', @P2 output, @P3 output, @P4 output
    select @P1, @P2, @P3, @P4
    go
    exec sp_cursorfetch 180150002, 16, 1, 1
    go
    declare @P1 int
    set @P1=1
    declare @P2 int
    set @P2=1
    exec sp_cursorfetch 180150002, 256, @P1 output, @P2 output
    select @P1, @P2
    go
    declare @P1 int
    set @P1=180150003
    declare @P2 int
    set @P2=1
    declare @P3 int
    set @P3=2
    declare @P4 int
    set @P4=1
    exec sp_cursoropen @P1 output, N'SELECT * from tbkc  where  kcid=5', @P2 output, @P3 output, @P4 output
    select @P1, @P2, @P3, @P4
    go
    exec sp_cursor 180150001, 33, 1, N'', @num = 11
    go
    declare @P1 int
    set @P1=180150004
    declare @P2 int
    set @P2=1
    declare @P3 int
    set @P3=2
    declare @P4 int
    set @P4=1
    exec sp_cursoropen @P1 output, N'SELECT tbuser.username, tbnianji.nianji, tbbanji.banji, tbpower.power FROM tbuser INNER JOIN ((tbpower INNER JOIN tbbanji ON tbpower.banjiid = tbbanji.banjiid) INNER JOIN tbnianji ON tbpower.nianjiid = tbnianji.nianjiid) ON (tbuser.banji = tbbanji.banji) AND (tbuser.nianji = tbnianji.nianji) WHERE (((tbuser.username)=''20080023''));', @P2 output, @P3 output, @P4 output
    select @P1, @P2, @P3, @P4
    go
    exec sp_cursorfetch 180150004, 16, 1, 1
    go
    declare @P1 int
    set @P1=1
    declare @P2 int
    set @P2=1
    exec sp_cursorfetch 180150004, 256, @P1 output, @P2 output
    select @P1, @P2
    go
    declare @P1 int
    set @P1=180150005
    declare @P2 int
    set @P2=1
    declare @P3 int
    set @P3=2
    declare @P4 int
    set @P4=1
    exec sp_cursoropen @P1 output, N'SELECT  * from tbscore  where username=''20080023''   and paperno=17', @P2 output, @P3 output, @P4 output
    select @P1, @P2, @P3, @P4
    go
    exec sp_cursorfetch 180150005, 16, 1, 1
    go
    declare @P1 int
    set @P1=1
    declare @P2 int
    set @P2=1
    exec sp_cursorfetch 180150005, 256, @P1 output, @P2 output
    select @P1, @P2
    go
      

  2.   

    1. 条件许可的话, 将sql和iis分别装到不同的服务器
    2. 检查你的表上是否有索引(主要针对查询条件的列和表join条件的列)
    3. 你贴的事件探察器跟踪的语句不太重要, 你应该重点分析持续时间长/CPU使用率高/IO高, 并且经常使用的语句
        而且就你贴的语句来看, 本来就不太复杂, 语句上没有什么好优化的, 但如果你的查询条件和join条件列上都没有索引, 那你要改的不是语句, 而是在表上建立索引(注意, 表中必须要有聚集索引(一般是主键), 索引才能有效的使用)