C# 执行查询时,页面响应非常慢
这很长,但我得写 1.我的网站上有100000种产品 数据库大小为7705.13 MB,使用sql server express 现在,,在我们将数据加载到会话中之前,在一个会话中,100000个产品,并根据要求对其进行过滤,就像我在一个页面上只需要30个一样,因此我将接受数据,其他人将根据要求加载数据,但存在性能问题,因此我们转向查询,现在我们使用类似的功能,如此 现在分页和排序在性能上很好 真正的问题我注意到页面在30秒时加载,现在它减少到12秒,但加载时间很长,所以我决定对它进行分析 因此,我在sql中执行查询需要00:00:00秒才能执行,但从c#开始调试时,将数据加载到数据表大约需要8秒或10秒左右,所以我认为标记的点是这样的,对此有什么建议吗?或者可能有其他情况?任何帮助都会得到感谢C# 执行查询时,页面响应非常慢,c#,asp.net,sql-server,performance,pagespeed,C#,Asp.net,Sql Server,Performance,Pagespeed,这很长,但我得写 1.我的网站上有100000种产品 数据库大小为7705.13 MB,使用sql server express 现在,,在我们将数据加载到会话中之前,在一个会话中,100000个产品,并根据要求对其进行过滤,就像我在一个页面上只需要30个一样,因此我将接受数据,其他人将根据要求加载数据,但存在性能问题,因此我们转向查询,现在我们使用类似的功能,如此 现在分页和排序在性能上很好 真正的问题我注意到页面在30秒时加载,现在它减少到12秒,但加载时间很长,所以我决定对它进行分析 因
public DataTable Load(string banner_type, int tag)
{
SqlDataAdapter dad = new SqlDataAdapter("index_master", cn);
dad.SelectCommand.CommandType = CommandType.StoredProcedure;
dad.SelectCommand.Parameters.AddWithValue("@condition", banner_type);
dad.SelectCommand.Parameters.AddWithValue("@tag", tag);
DataSet dset = new DataSet();
try
{
if (cn.State == ConnectionState.Closed)
cn.Open();
dad.Fill(dset, "banner_master");
return dset.Tables["banner_master"];
}
catch
{
throw;
}
finally
{
dset.Dispose();
dad.Dispose();
cn.Close();
cn.Dispose();
}
}
我用这个方法在我的整个网站上加载。提前谢谢
[更新]
SELECT TOP (100) PERCENT dbo.product_master.product_id, dbo.product_master.product_name , dbo.product_master.recommended_pro5, dbo.product_master.discount_group_id, dbo.product_master.active,''sale'' AS price_type, dbo.product_master.up_date,dbo.category_master.category_id, dbo.shipping_rule_master.shipping_id from product_master inner join.......
如果我不知道这是否是性能问题,请查看我缩小了一次数据库。
我的数据库产品结构
[1] :
[查询]
SELECT TOP (100) PERCENT dbo.product_master.product_id, dbo.product_master.product_name , dbo.product_master.recommended_pro5, dbo.product_master.discount_group_id, dbo.product_master.active,''sale'' AS price_type, dbo.product_master.up_date,dbo.category_master.category_id, dbo.shipping_rule_master.shipping_id from product_master inner join.......
DataAdapter/DataSet非常慢。虽然没有那么慢,但我觉得没有理由使用它们。谢谢你的回复,但是我应该用什么呢?你带回来什么?例如,您是将产品图像存储在数据库中还是基于app server的文件?您可以发布产品表的结构吗?一般建议:对用于筛选记录的列建立索引。这肯定会减少获取记录的时间。@AshishCharan——同意需要索引,但如果在SSM中毫不延迟地运行相同的精确查询,这不应该是问题所在。