DataGrid如何容纳10亿个数据? [英] How DataGrid can hold 1 Billion Data ?

查看:62
本文介绍了DataGrid如何容纳10亿个数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我通过执行大量查询从数据库中获取10亿个数据。

我需要在DataGrid中显示它逐页。执行查询时需要时间.Tried一些有用的链接。但它仅适用于SQL SERVER。我正在使用HP Vertica数据库。那我怎么能以优化的方式做到这一点



请建议。



Ajit

Hi

I have 1 Billion Data Coming from the DB by executing a Large Query.
I need to show it in DataGrid page by page. While executing query it is taking time.Tried Some useful link .but it is for SQL SERVER only. I am using HP Vertica Database . So how can I do this in an optimized way

please suggest.

Ajit

推荐答案

你必须实现分页。

你可以阅读(并使用我的C#代码和SQL代码)我的下一篇关于这个主题的文章:高级ASPX GridView分页和数据实体 [ ^ ]我在哪里实施分页数据库级别。
You have to implement pagination.
You could read (and use my C# code and SQL code from) my next article regarding this subject: Advanced ASPX GridView Pagination and Data Entities[^] where I implement pagination at the database level.


其他解决方案是使用LINQ在逻辑级别实现分页,如下例所示:



Other solution is to implement pagination at the logic level by using LINQ like in the next example:

public IQueryable<T> LoadGridData<T>(IQueryable<T> dataSource, int pageSize, int pageIndex, out int count)
{
    var query = dataSource;
    count = query.Count();
    //
    if (pageIndex < 1)
        pageIndex = 1;
    //
    var data = query.Skip((pageIndex - 1) * pageSize).Take(this.pageSize);
    return data;
}





所以你可以构建LINQ来获取数据,然后使用上面的方法来运行LINQ并且为了获得分页的数据,请参阅下面的示例:





So you could build LINQ for getting your data, then use a method like the one above to run the LINQ and to get the data paginated, see the example below:

 IQueryable<Order> ordersQuery = from o in dataContext.Orders
                                            from oi in dataContext.OrderItems
                                            where o.OrderItems.Count > 1 && oi.OrderID == o.ID && oi.WarehouseArticleID == this.ID
                                            orderby o.ID descending
                                            select o;
//Run the query ==>paginated results
int count;
IQueryable<Order> data = LoadGridData<Order>(ordersQuery , pageSize, pageIndex, out count);


您好,

一次获取所有数据是个坏主意,因为它太大而且会产生复杂性,所以你必须为此目的进行用户服务器端分页,通过它你只能获取那些数据这是必需的,它可以与服务器端分页实现。你也可以使用jquery进行服务器端分页。
Hi,
It is bad idea to fetch all data at one time b'cos its too large and create complexity, So you have to user server side paging for that purpose, through which you can fetch only that data which is required, it can be implemented with pagination with server side. also you can use jquery for server side paging.


这篇关于DataGrid如何容纳10亿个数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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