简体   繁体   English

显示报告的最佳做法

[英]Best practices for displaying reports

I currently have a client-server application. 我目前有一个客户端服务器应用程序。 The client needs to be able to generate reports. 客户端需要能够生成报告。 These reports can have millions of records. 这些报告可以包含数百万条记录。 What is the best way to get the data to the client? 将数据获取到客户端的最佳方法是什么? Sending all million records at once is not very efficient. 一次发送所有百万条记录不是很有效。 Let's say I just want to display 20 at a time and page through all the results. 假设我只想一次显示20,并在所有结果中逐页显示。 Would I have the server do the query each time a user clicks on next page or should I have the server get the entire result set and then sent parts of it to the client? 每次用户单击下一页时,我将让服务器执行查询吗?还是让服务器获取整个结果集,然后将其一部分发送给客户端?

Use a cursor - it is perfect for these purposes. 使用游标-非常适合这些目的。

Note - a report with million rows is not well designed report. 注意-具有百万行的报告不是设计合理的报告。 Nobady can process it. Nobady可以处理它。 But this is question for analytic. 但这是分析的问题。

http://www.commandprompt.com/ppbook/x15040 http://www.commandprompt.com/ppbook/x15040

I used Limit in sql query to set a range of records fetched. 我在sql查询中使用Limit来设置获取的记录范围。 but the query has to originate from client and the query must pass the range. 但查询必须源自客户端,并且查询必须通过范围。

It depends on scripting, if you use Dotnet+npgsql connector 如果您使用Dotnet + npgsql连接器,则取决于脚本

  • I would generate a Pagenumber in a combobox on form 我会在表单的组合框中生成一个页码
  • Then multiply the pagenumber with Rows*(pagenum-1) (20*1 for page2) to get starting rownum 然后将页码乘以Rows *(pagenum-1)(第2页为20 * 1)以获取开始的rownum
  • Pass it in form of sql to database 以sql形式将其传递给数据库
  • Retrieve rows and display in datagridview 检索行并在datagridview中显示

Although, i might just add, searching through a million record Page_by_page is not wisdom. 尽管我可能会补充说,但搜索一百万条Page_by_page记录并不明智。 i hope there are some filters to narrow down search to a few pages. 我希望有一些过滤器可以将搜索范围缩小到几页。 Because research show that views beyond page10 drop exponentially. 因为研究表明,超出第10页的观看次数呈指数下降。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM