」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > 最佳化效能:為資料透視表選擇最佳資料來源

最佳化效能:為資料透視表選擇最佳資料來源

發佈於2024-11-08
瀏覽:475

Optimize Performance: Choose the Best Data Source for Pivot Table

TL;DR: Syncfusion Pivot Table connects to multiple data sources, making it a versatile tool for data analysis. Selecting the right data source is crucial for performance. This guide explores different options and offers tips on choosing the best one.

Syncfusion Pivot Table is a powerful tool for data analysis and visualization. One of its standout features is the ability to connect to various data sources, making it a versatile choice for businesses and developers. Choosing the right data source for your Pivot Table is crucial for ensuring optimal performance and usability.

Let’s explore the different data sources you can connect to Syncfusion Pivot Table, their benefits, and how to choose the one that best suits your needs.

Understanding Syncfusion Pivot Table

Before diving into data sources, it’s essential to understand what the Syncfusion Pivot Table is and how it works. The Syncfusion Pivot Table is a component for ASP.NET MVC, ASP.NET Core, TypeScript, JavaScript, Angular, React, Vue, and Blazor platforms. It allows you to create interactive tables for data analysis, offering features like data filtering, sorting, grouping, and aggregation.

Factors to consider when choosing a data source for Pivot Table

Let’s see some of the significant factors that need to be considered when choosing a data source for our Pivot Table:

Data volume and complexity

The size of your data can affect performance. Large datasets might require more powerful databases or optimized storage solutions. For example, JSON or CSV files might be sufficient for small to medium datasets. For larger datasets, consider using Relational and NoSQL databases or OLAP systems. OLAP systems provide the necessary capabilities for complex data analysis and multi-dimensional data. For more straightforward analysis, JSON or CSV files can be practical.

Performance requirements

Consider the performance requirements of your app. Databases generally offer better performance for large-scale data operations compared to file-based data sources. However, JSON and CSV files might suffice for quick and straightforward analysis.

Ease of integration

Evaluate how easily the data source can be integrated with Syncfusion Pivot Table. Relational databases and JSON/XML files typically have well-established integration methods, while some NoSQL databases and RESTful APIs might require additional configuration.

Real-time data access

If your app requires real-time data access, use RESTful APIs or databases with real-time capabilities. File-based data sources like Excel and CSV are static and require manual updates.

Security and compliance

Ensure your chosen data source complies with your organization’s security and privacy requirements. Databases often provide robust security features, whereas file-based data sources might require additional measures to secure sensitive information.

Best practices for choosing a data source for Pivot Table

Let’s see some of the best practices for choosing a data source for a Pivot Table:

Evaluate your use case

Understand your app’s specific needs and choose a data source that aligns with those needs. Consider the data type, required operations, and user expectations. Consider NoSQL databases for web apps that require high availability and scalability. Relational databases like SQL Servers are a good choice for traditional business apps that use structured data.

Test performance and scalability

Conduct performance testing to ensure the chosen data source can handle the expected load. Also, consider future scalability needs and choose a solution that can grow with your app.

Ensure data quality

Data quality is paramount for accurate analysis. Choose data sources that allow you to maintain high data quality standards, including validation and error checking.

Plan for data integration

Develop a clear plan for integrating your data source with Syncfusion Pivot Table. Consider using middleware or ETL (Extract, Transform, Load) tools to streamline the integration process. JSON and CSV data are convenient for quick setups and ease of use. Relational databases and OLAP systems require more setup and maintenance but offer greater capabilities.

How does the Syncfusion Pivot Table work with different data sources?

The flexible and robust data binding capabilities facilitate Syncfusion Pivot Table’s ability to work with various data sources. It supports multiple data sources, including:

  • JSON data: Ideal for small to medium datasets, JSON is lightweight and easy to work with.
  • OLAP (Online Analytical Processing): Suitable for large datasets and complex data analysis.
  • Relational databases: SQL databases like MySQL, SQL Server, and PostgreSQL provide robust data storage and querying capabilities.
  • NoSQL databases: NoSQL databases like MongoDB provide a flexible schema design for unstructured data.
  • Web Services: Web Services, such as RESTful APIs and OData services, are helpful for real-time data integration and dynamic updates.
  • CSV files: Simple for smaller datasets and quick setups.

JSON data

JSON (JavaScript Object Notation) is a lightweight data interchange format. Syncfusion Pivot Table can easily consume JSON data, which is particularly useful for web apps where data is often fetched in JSON format from APIs.

Advantages

  • Ease of use: JSON is easy to read, write, and parse, making it a popular choice for web apps.
  • Flexibility: JSON can handle various data structures, including nested objects and arrays.

  • Lightweight: JSON is compact, reducing the data transmitted over the network.

Considerations

  • Performance: Handling large datasets in JSON can be inefficient and slow.

  • Limited Scalability: JSON is not ideal for large or complex datasets.

When to use

  • Small to medium datasets.
  • Apps where ease of use and quick setup are priorities.

  • Prototyping and testing.

Here is a code example for integrating JSON data with our Pivot Table.

Binding JSON data via local

var localData = [
    { Product: 'Bike', Country: 'USA', Sales: 100 },
    { Product: 'Car', Country: 'Canada', Sales: 200 }
];

var pivotTableObj = new ej.pivotview.PivotView({
    dataSourceSettings: {
        dataSource: localData,
        rows: [{ name: 'Product' }],
        columns: [{ name: 'Country' }],
        values: [{ name: 'Sales' }],
        filters: []
    }
});
pivotTableObj.appendTo('#PivotTable');

Binding JSON data via remote (external) link

var pivotGridObj = new ej.pivotview.PivotView({
    dataSourceSettings: {
        url: 'https://cdn.syncfusion.com/data/sales-analysis.json',
        expandAll: false,
        rows: [
            { name: 'EnerType', caption: 'Energy Type' }
        ],
        columns: [
            { name: 'EneSource', caption: 'Energy Source' }
        ],
        values: [
            { name: 'PowUnits', caption: 'Units (GWh)' },
            { name: 'ProCost', caption: 'Cost (MM)' }
        ],
        filters: []
    }
});
pivotGridObj.appendTo('#PivotTable');

CSV files

Comma-separated values (CSV) files are a standard format for exporting and importing data. Syncfusion Pivot Table can parse CSV files and use them as a data source, making it convenient to analyze data from spreadsheets or other tabular data sources.

Advantages

  • Simplicity: Easy to create, read, and manipulate.
  • Portability: CSV files are widely supported and easily shareable.
  • Quick setup: Ideal for quick setups and small datasets.

Considerations

  • Performance: Not suitable for large datasets or complex queries.
  • Limited functionality: Lacks advanced features and data types.

When to use

  • Small datasets for quick analysis or prototyping.
  • Data migration or import/export scenarios.
  • Simple apps with minimal data manipulation needs.

Here is a code example for integrating CSV data with Pivot Table.

Binding CSV data via local

var csvdata =
  'Region,Country,Item Type,Sales Channel,Total Revenue,Total Cost,Total Profit\r\nMiddle East and North Africa,Libya,Cosmetics,Offline,3692591.20,2224085.18,1468506.02\r\nNorth America,Canada,Vegetables,Online,464953.08,274426.74,190526.34\r\nMiddle East and North Africa,Libya,Baby Food,Offline,387259.76,241840.14,145419.62\r\nAsia,Japan,Cereal,Offline,683335.40,389039.42,294295.98';
var pivotObj = new ej.pivotview.PivotView({
  dataSourceSettings: {
    dataSource: getCSVData(),
    type: 'CSV',
    expandAll: false,
    formatSettings: [
      { name: 'Total Cost', format: 'C0' },
      { name: 'Total Revenue', format: 'C0' },
      { name: 'Total Profit', format: 'C0' },
    ],
    drilledMembers: [{ name: 'Item Type', items: ['Baby Food'] }],
    rows: [{ name: 'Country' }, { name: 'Region' }],
    columns: [{ name: 'Sales Channel' }, { name: 'Item Type' }],
    values: [
      { name: 'Total Profit' },
      { name: 'Total Cost' },
      { name: 'Total Revenue' },
    ],
    filters: [],
  },
  height: 290,
  width: '100%',
});
pivotObj.appendTo('#PivotTable');
function getCSVData() {
  var dataSource = [];
  var jsonObject = csvdata.split(/\r?\n|\r/);
  for (var i = 0; i 



Binding CSV data via remote (external) link

var pivotObj = new ej.pivotview.PivotView({
    dataSourceSettings: {
        url: 'https://bi.syncfusion.com/productservice/api/sales',
        type: 'CSV',
        expandAll: false,
        enableSorting: true,
        formatSettings: [{ name: 'Total Cost', format: 'C0' }, { name: 'Total Revenue', format: 'C0' }, { name: 'Total Profit', format: 'C0' }],
        drilledMembers: [{ name: 'Item Type', items: ['Baby Food'] }],
        rows: [
            { name: 'Region' },
            { name: 'Country' }
        ],
        columns: [
            { name: 'Item Type' },
            { name: 'Sales Channel' }
        ],
        values: [
            { name: 'Total Cost' },
            { name: 'Total Revenue' },
            { name: 'Total Profit' }
        ],
        filters: []
    },
    height: 300,
    width: '100%'
});
pivotObj.appendTo('#PivotTable');

OLAP (Online Analytical Processing) data

OLAP cubes allow for complex data analysis and are commonly used in business intelligence apps. Syncfusion Pivot Table supports OLAP data sources, enabling multi-dimensional data analysis with rich, hierarchical data structures. OLAP data sources often provide faster query responses due to pre-aggregated data.

Advantages

  • Performance: OLAP is designed for fast querying and data analysis, even with large datasets.
  • Complex analysis: Supports complex calculations, aggregations, and multi-dimensional data analysis.
  • Scalability: OLAP systems can handle massive datasets with ease.

Considerations

  • Complexity: Setting up and maintaining an OLAP system can be complex and require specialized knowledge.
  • Cost: OLAP solutions can be expensive to implement and maintain.

When to use

  • Large datasets with complex analysis requirements.
  • Business intelligence and data warehousing apps.
  • Scenarios requiring high performance and scalability.

Here is a code example for integrating the OLAP data with the Pivot Table.

var pivotTableObj = new ej.pivotview.PivotView({
    dataSourceSettings: {
            catalog: 'Adventure Works DW 2008 SE',
            cube: 'Adventure Works',
            providerType: 'SSAS',
            enableSorting: true,
            url: 'https://bi.syncfusion.com/olap/msmdpump.dll',
            localeIdentifier: 1033,
            rows: [{ name: '[Customer].[Customer Geography]'],
            columns: [{ name: '[Product].[Product Categories]'},
                { name: '[Measures]'}],
            values: [{ name: '[Measures].[Customer Count]'},
                { name: '[Measures].[Internet Sales Amount]']
    }
});
pivotTableObj.appendTo('#PivotTable');

Relational databases

Relational databases are one of the most common data sources for our Pivot Table. They store data in tables, making it easy to retrieve and manipulate data using SQL queries. Popular relational databases include MySQL, PostgreSQL, SQL Server, and Oracle.

Advantages

  • Structured data: Data is organized in a tabular format, ideal for Pivot Tables.
  • Scalability: Suitable for handling large volumes of data.
  • ACID compliance: Ensures data integrity and consistency.

Considerations

  • Complexity: Requires knowledge of SQL for data retrieval.
  • Performance: This may require optimization for large datasets.

When to use

  • Medium to large datasets.
  • Apps requiring robust data storage and complex queries.
  • Scenarios where data integrity and relationships are essential.

NoSQL databases

NoSQL databases such as MongoDB offer a flexible schema and are designed to handle unstructured data, making them a good choice for certain types of data analysis.

Advantages

  • Flexibility: Schema-less design allows for easy modification of data structures.
  • Scalability: Excellent for handling large-scale, distributed data.

Considerations

  • Query complexity: Can be more complex to query than relational databases.
  • Consistency: May sacrifice consistency for availability and partition tolerance (CAP theorem).
  • Connectivity: We may require specific connectors or APIs for integration.

Web Services or remote data

Data can be fetched from remote servers using web services or APIs. Syncfusion Pivot Table can connect to remote data sources via RESTful services, making it ideal for apps that analyze data from various endpoints. It involves retrieving data from remote servers or databases.

Advantages

  • Real-time data: Enables real-time data integration and dynamic updates.
  • Scalability: Can handle large and distributed datasets.
  • Flexibility: Easily integrate with various services and APIs.

Considerations

  • Complexity: Requires developing and maintaining RESTful APIs.
  • Latency: Network latency can impact performance.

When to use

  • Apps needing real-time data updates.
  • Integrating data from multiple sources or external APIs.
  • Scenarios requiring high flexibility and scalability.

Here’s a code example for connecting an API service to our Pivot Table.

var data = new ej.data.DataManager({
    url: 'https://bi.syncfusion.com/northwindservice/api/orders',
    adaptor: new ej.data.WebApiAdaptor(),
    crossDomain: true,
  });
  data.defaultQuery = new ej.data.Query().take(8);

  var pivotTableObj = new ej.pivotview.PivotView({
    dataSourceSettings: {
      dataSource: data,
      expandAll: true,
      filters: [],
      columns: [{ name: 'ProductName' }],
      rows: [{ name: 'ShipCountry' }, { name: 'ShipCity' }],
      formatSettings: [{ name: 'UnitPrice', format: 'C0' }],
      values: [{ name: 'Quantity' }, { name: 'UnitPrice' }],
    },
    height: 350,
    width: '100%',
    gridSettings: { columnWidth: 120 },
  });
  pivotTableObj.appendTo('#PivotTable');

References

For more details, refer to the following references:

  • Connecting to PostgreSQL in Pivot Table
  • Connecting to Microsoft SQL Server in Pivot Table
  • Connecting to Oracle in Pivot Table
  • Connecting to Elasticsearch in Pivot Table
  • Connecting to Snowflake in Pivot Table
  • Server-Side Pivot Engine in Pivot Table

Conclusion

Thanks for reading! In this blog, we’ve explored the various options, benefits, and best practices for choosing the right data source for the Syncfusion Pivot Table, ensuring optimal performance and usability.

If you’re already a Syncfusion user, the latest version of Essential Studio is available on the License and Downloads page. We offer our new users a 30-day free trial to explore all our components’ features and capabilities.

If you need further assistance, contact us via our support forum, support portal, or feedback portal. We’re always here to help you!

Related blogs

  • Easily Group Data into Ranges in Web Applications Using Pivot Table
  • Optimize Memory Management in JavaScript Pivot Table: Best Practices and Tips
  • Easily Perform CRUD Actions in Blazor Pivot Table with SQL Database & Entity Framework
  • Efficient Report Management: Save and Load Reports in Vue Pivot Table with SQL Server and Node.js Express Server
版本聲明 本文轉載於:https://dev.to/syncfusion/optimize-performance-choose-the-best-data-source-for-pivot-table-3l0e?1如有侵犯,請聯絡[email protected]刪除
最新教學 更多>
  • 釋放 Claude AI:用於經濟實惠且靈活的 AI 整合的非官方 API
    釋放 Claude AI:用於經濟實惠且靈活的 AI 整合的非官方 API
    由 Anthropic 開發的 Claude AI 以其令人印象深刻的能力在人工智慧界掀起了波瀾。然而,官方 API 對於許多開發人員和小型企業來說可能過於昂貴。這就是我們的非官方 Claude AI API 的用武之地,它提供了一個更實惠、更靈活的解決方案,將 Claude 的力量整合到您的專案中...
    程式設計 發佈於2024-11-08
  • 如何使用時間包確定 Go 中一個月的最後一天?
    如何使用時間包確定 Go 中一個月的最後一天?
    使用Time.Time 確定給定月份的最後一天處理基於時間的資料時,通常需要確定指定月份的最後一天。無論該月有 28 天、29 天(閏年)還是 30 天或 31 天,這都會使這成為一項具有挑戰性的任務。 時間包解決方案Go 時間包其日期函數提供了一個方便的解決方案。 Date 的語法為:func D...
    程式設計 發佈於2024-11-08
  • 如何在不支援的瀏覽器中實現“背景濾鏡”效果?
    如何在不支援的瀏覽器中實現“背景濾鏡”效果?
    CSS:為不可用的背景過濾器提供替代方案CSS 中的背景過濾器功能在大多數現代瀏覽器中仍然無法訪問。雖然我們預計其未來的支持,但發現替代解決方案勢在必行。 實現類似效果的一種方法是採用具有微妙透明度的背景。下面的 CSS 程式碼示範了這個方法:/* Slightly transparent fall...
    程式設計 發佈於2024-11-08
  • Python 的 len() 函數對於不同的資料結構有多有效率?
    Python 的 len() 函數對於不同的資料結構有多有效率?
    理解Python內建資料結構中len()函數的成本Python中內建len()函數是決定各種資料結構長度的重要工具。它的效率至關重要,尤其是在處理大型資料集時。本文深入研究了 len() 對於不同內建資料類型(例如列表、元組、字串和字典)的計算成本。 O(1) 跨內建類型的複雜性關鍵要點是 len(...
    程式設計 發佈於2024-11-08
  • 如何在 Python 中存取 Windows 剪貼簿文字?
    如何在 Python 中存取 Windows 剪貼簿文字?
    在 Python 中存取 Windows 剪貼簿文字從 Windows 剪貼簿檢索文字是程式設計中的常見任務。本文探討如何使用 Python 的 win32clipboard 模組來實現此目的。 pywin32 和 win32clipboardwin32clipboard 模組是 pywin32 的...
    程式設計 發佈於2024-11-08
  • 如何修復 CentOS 5 上由於檔案權限問題導致的 Nginx 403 Forbidden 錯誤?
    如何修復 CentOS 5 上由於檔案權限問題導致的 Nginx 403 Forbidden 錯誤?
    Nginx 403 Forbidden:文件存取權限故障排除當在Nginx 中遇到令人沮喪的「403禁止」錯誤時,確定根本原因可以是一個挑戰。此錯誤通常表示對檔案或目錄的存取被拒絕。在該特定場景中,使用者在 CentOS 5 上使用 PHP-FPM 配置了 Nginx,但無法提供指定來源目錄中的任何...
    程式設計 發佈於2024-11-08
  • React 中的函數和類別元件與 TypeScript
    React 中的函數和類別元件與 TypeScript
    在使用 TypeScript 的 React 中,我們可以使用兩種主要方法來建立元件:功能元件和類別元件。兩種方法都允許使用 props 和 state,但使用的範例略有不同。 TypeScript 透過提供靜態類型進一步增強了開發安全性,這使我們能夠精確定義 props 和 state 的形狀。 ...
    程式設計 發佈於2024-11-08
  • 如何使用 Clang 檢查編譯器產生的 C++ 模板實例化程式碼?
    如何使用 Clang 檢查編譯器產生的 C++ 模板實例化程式碼?
    檢查C 語言中編譯器產生的範本實例化在C 語言中,範本函數和類別允許透過定義通用功能來重用程式碼專門針對不同類型。要了解編譯器為模板實例化產生的程式碼,了解這些實例化的函數或類別會很有幫助。 Clang 的AST 列印功能一個工具提供這種可見性的是Clang 的抽象語法樹(AST) 列印功能,Cla...
    程式設計 發佈於2024-11-08
  • 我從使用 Vue.js 建立計算器中學到了什麼
    我從使用 Vue.js 建立計算器中學到了什麼
    對於我的第四個項目,我使用 Vue.js 開發了一個 計算器 應用程式。對於理解如何處理使用者輸入、顯示動態結果以及使用 JavaScript 執行計算來說,這是一次寶貴的經驗。以下是我在建立此應用程式時學到的主要經驗教訓的細分。 1. 處理使用者輸入並更新顯示 計算器需要接受使用...
    程式設計 發佈於2024-11-08
  • 在 Kubernetes 上設定 JFrog Artifactory 並連接 Spring Boot 應用程式
    在 Kubernetes 上設定 JFrog Artifactory 並連接 Spring Boot 應用程式
    本文档提供有关在 Kubernetes 集群中设置 JFrog Artifactory 的指南。它作为开发人员在本地计算机上运行的 Kubernetes 环境上安装和配置 JFrog 的基本教程。 设置本地环境来构建DevOps资源 我使用 Docker 容器为多个应用程序设置工作环...
    程式設計 發佈於2024-11-08
  • Angular 與 React:4 中你該選哪一個?
    Angular 與 React:4 中你該選哪一個?
    前端開發者總是面臨一個大問題:Angular 還是 React? 兩個框架都很強大,但哪一個真正適合你的開發需求? ? 在這個全面的比較中,我詳細分析了每個項目的主要差異、優勢和劣勢,幫助您為下一個項目做出正確的選擇。無論您是初學者還是經驗豐富的專業人士,本文都會為您提供做出明智決定所需的見解。...
    程式設計 發佈於2024-11-08
  • 如何將 Props 傳遞給 React Router 中的處理程序元件?
    如何將 Props 傳遞給 React Router 中的處理程序元件?
    使用React Router 將Props 傳遞給處理程序元件在利用React Router 的React.js 應用程式中,您可能會遇到需要將props 傳遞給特定處理程序組件的場景。考慮以下應用程式結構:var Dashboard = require('./Dashboard'); var Co...
    程式設計 發佈於2024-11-08
  • 透過 Maroto 在 Golang 中產生 PDF 來進行長期操作
    透過 Maroto 在 Golang 中產生 PDF 來進行長期操作
    Written by Subha Chanda✏️ Go, also known as Golang, is a statically typed, compiled programming language designed by Google. It combines the performan...
    程式設計 發佈於2024-11-08
  • 作業系統開發(真相)
    作業系統開發(真相)
    Table of Contents Introduction 1. The Bootloader: Kicking Things Off 2. Entering the Kernel: Where the Magic Happens 3. Choosing Your Languag...
    程式設計 發佈於2024-11-08
  • 按值傳遞或引用傳遞:「想要速度?按值傳遞」何時是真的?
    按值傳遞或引用傳遞:「想要速度?按值傳遞」何時是真的?
    “想要速度?按價值傳遞” - 探索性能影響Scott Meyers 的聲明“想要速度?按價值傳遞”提出了問題關於按值傳遞物件與按引用傳遞物件的效能優勢。在這種情況下,按值傳遞涉及複製操作,而按引用傳遞則避免了不必要的複製。 考慮以下結構體 X 和 Y 的例子:struct X { std::st...
    程式設計 發佈於2024-11-08

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3