从Sql Server DB获取数据的最快方法 [英] Fastest way to get the Data from Sql Server DB

查看:87
本文介绍了从Sql Server DB获取数据的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我们在SQL Server数据库中有数十亿条记录,我需要使用我的Windows应用程序读取这些数据。



当我在SQL Server中执行脚本(内部连接2个表)时,我能够在40秒内看到结果,但是当运行我的Windows应用程序时,它需要超过一分钟。



我在我的应用程序中编写的代码:



Hi,

We have the billions of records in the SQL Server DB, and I need to read that data using my Windows Application.

When I execute the Script (Inner Joining 2 tables) in the SQL Server I am able to see the result in 40 secs, But when run my windows application it is taking more than one min.

here in the Code I written in my app:

private DataSet GetData(string query, string dbName)
        {
            try
            {
                DataSet ds = new DataSet();
                con = new SqlConnection(GetConnectionString(dbName));
                con.Open();
                da = new SqlDataAdapter(query, con);
                con.Close();
                
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Excess Static Data", MessageBoxButton.OK, MessageBoxImage.Error);
                return null;
            }
        }





数据集花费很多时间来获取数据。



有没有最快的方法让数据少于10秒。



问候,

Murali。



Dataset is taking much time to get the data.

Is there any fastest way to get the data less than 10sec.

Regards,
Murali.

推荐答案

试试这个:





而不是使用dataSet你可以使用dataReader,它将是高效的
Try this:


instead of using dataSet you can use dataReader, it will be efficient


这篇关于从Sql Server DB获取数据的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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