DataTable中加载很慢 [英] DataTable Load very slow

查看:2148
本文介绍了DataTable中加载很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个数据表作为页面上一些的下拉列表中的数据源,但已经注意到页面是回发时非常缓慢。

I'm using a datatable as the datasource of some dropdowns on a page, but have noticed that the page is very slow during the postbacks.

我已经跟踪它通过在这里:

I've tracked it through to here:

DataTable dt = new DataTable();
dt.Load(sqlCmd.ExecuteReader()); // this takes ages

SQL命令是一个parametrised查询,而不是一个存储过程(返回值和在哪里都相当动态所以这不会是可行的),但尽管如此,一个简单的选择联合查询。
通常返回每个下拉选项5和20之间,这取决于对其他下拉列表中选择。
当我运行在Management Studio中的查询,这是一个第二下做英寸这可能需要长达7秒每下拉列表中,它很快就增加了第6页的下拉列表中。
我也试图与一个SqlDataAdapter:

The sql command is a parametrised query, not a stored procedure (the return values and where are quite 'dynamic' so this wouldn't be practicable), but nevertheless a simple select union query. Usually returns between 5 and 20 options per dropdown, depending on what's been selected on the other dropdowns. When I run the query in the management studio, it's done in under a second. Here it can take up to 7 seconds per dropdown, with 6 dropdowns on the page it soon adds up. I have also tried with a SqlDataAdapter:

SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt); // this takes ages

但是这只是慢。
我有这样的2个不同的系统和具有相同的性能问题。

but this was just as slow. I have this on 2 different systems and on both have the same performance issues.

如果有人知道一个更好的(快)方法,给出或知道这是为什么这么慢,这将是巨大的。

If anyone knows a better (faster) methord, or knows why this is so slow that would be great.

推荐答案

不是最好的线程我看到在这个问题上,但里面有良好的关系,与放大器;它在我的帖子历史:

Not the best thread I've seen on the issue, but there's good links inside, & it's in my post history:

<一个href=\"http://stackoverflow.com/questions/15010892/sql-query-that-runs-fine-in-ssms-runs-very-slow-in-asp-net/15012264#15012264\">SQL运行在SSMS精细查询的运行速度很慢在ASP.NET

SQL优化有时喜欢来决定什么是最好的和放大器;你必须通过数据执行计划的一些跟踪和记录,打破了查询。这很可能是一些埋藏的坏的索引,或者您的查询code可能需要优化。眼看因为我们没有查询code和有它可能会或可能不会有帮助。我建议你​​按照上面的帖子挂导游并关闭您的问题。

The SQL Optimizer sometimes likes to decide what's best & you'll have to break out your query through some tracing and logging of data execution plans. It may very well be something as buried as a bad index, or your query code might need optimization. Seeing as we don't have the query code, and having it may or may not be helpful. I'd recommend you follow the guides linked to in the above post and close your question.

这篇关于DataTable中加载很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆