Using Set Processing Effectively 有效地使用集合处理
Using Set Processing Effectively 有效地使用集合处理
The information in the topics that follow applies if you are developing new or upgrading older Application Engine programs to adhere to a set-based model.
如果要开发新的应用程序引擎程序或升级旧的应用程序引擎程序以遵循基于集的模型,则以下主题中的信息适用。
SQL Expertise SQL专业知识
You should be a SQL expert if you are developing row-by-row programs with Application Engine and especially if you are developing set-based programs. The following concepts are particularly important:
如果使用应用程序引擎开发逐行程序,尤其是开发基于集合的程序,那么您应该是SQL专家。以下几个概念尤为重要:
- Group by and Having clauses.
- group by 和 having 子句。
- Complex joins.
- 复杂的联接。
- Subqueries (correlated and non-correlated).
- 子查询(相关的和不相关的)。
- Tools for your database to analyze complex SQL statements for performance analysis.
- 为您的数据库分析复杂的SQL语句进行性能分析的工具。
Typically, you use these SQL constructs to refine or filter a set to contain only the rows that meet specific criteria. In Application Engine, you code using SQL, and Application Engine passes that SQL directly to the database, where it is processed. If you have a complex SQL statement that works functionally, it may not perform well if it is not tuned properly.
通常,您使用这些SQL构造来优化或筛选一个集合,使其仅包含满足特定条件的行。在应用程序引擎中,使用SQL进行编码,应用程序引擎将该SQL直接传递到数据库,并在数据库中对其进行处理。如果您有一个在功能上工作的复杂SQL语句,如果没有适当地调优,它的性能可能不会很好。
Planning 规划
Well-constructed, robust, and efficient Application Engine programs are usually the product of a detailed planning stage in which loops, program flow, the use of temporary tables, sections, steps, and so on are discussed.
构造良好、健壮且高效的应用程序引擎程序通常是详细规划阶段的产物,在该阶段中讨论了循环、程序流、临时表、节、步骤等的使用。
Ideally, you should address batch processing as a whole while you are designing the system. Sometimes, system analysts and developers focus primarily on the online system during the database design, and then they consider the batch component within the existing database design. Set processing works best in an environment in which data models are optimized for set processing.
理想情况下,您应该在设计系统时将批处理作为一个整体来处理。有时,系统分析师和开发人员在数据库设计过程中主要关注在线系统,然后在现有的数据库设计中考虑批处理组件。集合处理在数据模型为集合处理进行优化的环境中工作得最好。
For example, you could have a separate staging table for new data that has not been processed rather than having numerous cases of existing rows in a table being updated. In set processing, processing the data after moving it to a temporary table using an Insert or Select statement is easier than using an update.
Avoid performing updates on real application tables, and try to perform your updates on temporary tables. You can structure your data model to minimize updating real application tables.
例如,对于尚未处理的新数据,可以使用一个单独的staging表,而不是对表中的现有行进行多次更新。在集合处理中,使用Insert或Select语句将数据移动到临时表后再对其进行处理比使用update更容易。避免在实际应用程序表上执行更新,并尝试在临时表上执行更新。您可以构造数据模型以尽量减少实际应用程序表的更新。
Another important consideration is keeping historical data separate from active transactions. After the life cycle of given piece of transaction data is over, so that no more updates are possible, consider moving that data to an archive or history table and deleting it from the real transaction table. This action minimizes the number of rows in the table, which improves performance for queries and updates to your active data.
另一个重要的考虑是将历史数据与活动事务分开。在给定的事务数据块的生存周期结束之后,因此不再可能进行更新,可以考虑将该数据移动到归档或历史表中,并从实际的事务表中删除它。此操作可最大限度地减少表中的行数,从而提高查询和更新活动数据的性能。
Temporary Tables 临时表
Although temporary tables are not required for set processing, well-designed temporary tables complement your set-based program in a variety of ways.
虽然集合处理不需要临时表,但是设计良好的临时表可以以各种方式补充基于集合的程序。
Creating temporary tables enables you to achieve one of the main objectives of set-based processing: the processing remains on the database server. By storing transient data in temporary tables, you avoid the batch program fetching the data, row by row, and running the business rule, processing the data, and then passing the updated data back to the database. If the program ran on the client, you would encounter performance issues because of the network round-trip and the diminished processing speed of a client compared to the database platform.
创建临时表使您能够实现基于集的处理的主要目标之一:处理保留在数据库服务器上。通过将临时数据存储在临时表中,可以避免批处理程序逐行获取数据、运行业务规则、处理数据,然后将更新的数据传递回数据库。如果程序在客户机上运行,您将遇到性能问题,因为网络往返和与数据库平台相比客户机的处理速度降低。
Design your temporary tables to:
将临时表设计为:
- Hold transaction data for the current run or iteration of your program.
- 保存程序当前运行或迭代的事务数据。
- Contain only those rows of data affected by the business rule.
- 仅包含受业务规则影响的数据行。
- Present key information in a denormalized, or flattened, form, which provides the most efficient processing.
- 以非规范化或扁平化的形式呈现关键信息,这提供了最有效的处理方式。
- Switch the keys for rows coming from the master tables, if needed.
- 如果需要,为来自主表的行切换键。
A transaction may use a different key than what appears in the master tables.
事务可以使用与主表中显示的不同的键。
Denormalized Tables 非正规化表
The most efficient temporary tables store data in denormalized form. Because most programs need to access data that resides in multiple tables, you should consolidate all of the affected and related data into one table, a temporary table. The program runs more efficiently against a flattened, temporary table rather than relying on the system to materialize complex joins and views to retrieve or update necessary data for each transaction.
最有效的临时表以非规范化的形式存储数据。因为大多数程序需要访问驻留在多个表中的数据,所以应该将所有受影响的相关数据合并到一个表(临时表)中。程序在一个扁平的临时表上运行的效率更高,而不是依赖于系统来具体化复杂的连接和视图,以便为每个事务检索或更新必要的数据。
If your program requires the use of a complex view to process transactions, then resolve the view into a temporary table for your program to run against. Each join or view that needs to materialize for each transaction consumes system resources and affects performance. In this approach, the system applies the join or view once (during the filtering process), populates the temporary table with the necessary information that the program needs to complete the transaction, and then runs the program against the temporary table as needed.
如果您的程序需要使用复杂的视图来处理事务,那么请将该视图解析为一个临时表,以便程序在其上运行。需要为每个事务实现的每个联接或视图都会消耗系统资源并影响性能。在这种方法中,系统应用一次联接或视图(在过滤过程中),用程序完成事务所需的必要信息填充临时表,然后根据需要对临时表运行程序。
For example, consider the following situation:
例如,考虑下面的情况:
A program needs to update 10,000 rows in the Customer table, which contains 100,000 rows of data. The Customer table is keyed by setID. To complete the transaction, the program references data that resides in a related table called PS_SET_CNTRL_REC. PS_SET_CNTRL_REC is used to associate setID and BUSINESS_UNIT values. The transaction is keyed by BUSINESS_UNIT.
一个程序需要更新Customer表中的10,000行,该表包含100,000行数据。Customer表由setID键控。为了完成事务,程序引用驻留在名为PS_SET_CNTRL_REC的相关表中的数据。PS_SET_CNTRL_REC用于关联setID和BUSINESS_UNIT值。事务由BUSINESS_UNIT键控
Given this set of circumstances, the most efficient processing method would be similar to the following:
考虑到这组情况,最有效的处理方法将类似于以下方法:
- Isolate affected or necessary data from both tables and insert it into a temporary table.
- ·从两个表中隔离受影响的或必要的数据,并将其插入到临时表中。
Now, instead of dealing with a 10,000-row Customer table and a join to a related table, the program faces a 10,000-row temporary table that contains all of the required data to join directly to the transaction data, which can also be in a temporary table. If all necessary columns reside in the temporary tables, then the program can modify all the rows at once in a simple Update statement.
现在,程序面对的不是一个10,000行的Customer表和一个到相关表的联接,而是一个10,000行的临时表,其中包含直接联接到事务数据所需的所有数据,这些数据也可以在一个临时表中。如果所有必要的列都驻留在临时表中,那么程序可以在一个简单的Update语句中一次性修改所有行。
This example presents two different uses of temporary tables. In one situation, the temporary table is designed to hold setup and control data in a modified form. In the other situation, the temporary table is designed to hold transaction data in a denormalized form, perhaps with additional work columns to hold intermediate calculations.
本例展示了临时表的两种不同用法。在一种情况下,临时表被设计成以修改后的形式保存设置和控制数据。在另一种情况下,临时表被设计为以非规范化的形式保存事务数据,可能还有额外的工作列来保存中间计算。
- Make sure the data appears in a denormalized form for optimum processing.
- 确保数据以非规范化的形式出现,以便进行最佳处理。
- Because the transaction is keyed by BUSINESS_UNIT, you should also key the temporary table that holds the control data by BUSINESS_UNIT.
- 因为事务是由BUSINESS_UNIT键控的,所以还应该由BUSINESS_UNIT键控保存控制数据的临时表。
In this case, the table that holds the control data is the Customer table.
在这种情况下,保存控制数据的表是Customer表。
相关文章:
Using Set Processing Effectively 有效地使用集合处理
Using Set Processing Effectively 有效地使用集合处理 The information in the topics that follow applies if you are developing new or upgrading older Application Engine programs to adhere to a set-based model. 如果要开发新的应用程序引擎程序或升级旧的应用程序…...
HarmonyOS开发Java与ArkTS如何抉择
在“鸿蒙系统实战短视频App 从0到1掌握HarmonyOS”视频课程中,很多学员来问我,在HarmonyOS开发过程中,面对Java与ArkTS,应该选哪样? 本文详细分析Java与ArkTS在HarmonyOS开发过程的区别,力求解答学员的一些…...
“茶叶创新:爆改营销策略,三个月狂销2300万“
我的朋友去年制作了一款白茶,并在短短三个月内将其销售量推到了2300万的高峰。你相信吗? 这位朋友并没有任何茶叶方面的经验,他只是一个有着冒险精神的企业家。他先找到了一家代工厂,帮助他把他的茶叶理念转化为现实。 当他把茶叶…...
分享一个生成哈希值的C代码
代码是我在阅读assimp源码时看到的,不依赖任何第三方,可直接集成。 #pragma once #ifndef AI_HASH_H_INCLUDED #define AI_HASH_H_INCLUDED#ifdef __GNUC__ # pragma GCC system_header #endif#include <stdint.h> #include <string.h> #…...
【Windows 常用工具系列 11 -- 福昕PDF搜索高亮过的文本】
文章目录 福昕 PDF 搜索高亮过的文本 福昕 PDF 搜索高亮过的文本 在 pdf 文档阅读过程中,我们需要经常高亮一些文本,以方便下次阅读时找到重点。我这边使用的是 福昕PDF 阅读器,下面就介绍下如何在福昕阅读器中搜索已经高亮过的文本。...
(二)汇编语句组成
一个完整的 RISC-V 汇编程序有多条 语句(statement) 组成。 一条典型的 RISC-V 汇编 语句 由 3 部分组成: 1.标签 List item label(标签): 标签是标识程序位置的记号。通常定义一个名称然后加上":"后缀。…...
Linux C 网络编程概述
网络编程 计算机网络概述分类网络体系结构通信协议通信流程网络通信帧格式以太网帧格式分析ARP 协议分析IP 数据报分析IP分类IP 分配子网掩码 TCP 段分析 TCP三次握手协议 ⭐TCP四次挥手协议 ⭐ TCP编程基于 TCP 客户端编程-步骤说明基于 TCP 服务器端编程-步骤说明基于 TCP 服…...
腾讯云标准型s5和s6有什么区别?CPU处理器有差异吗?
腾讯云服务器CVM标准型S5和S6有什么区别?都是标准型云服务器,标准型S5是次新一代云服务器规格,标准型S6是最新一代的云服务器,S6实例的CPU处理器主频性能要高于S5实例,同CPU内存配置下的标准型S6实例要比S5实例性能更好…...
WPF TextBox实现placeholder
WPF里TextBox没有placeholder,需要自己实现,本篇博客介绍WPF TextBox实现placeholder,效果如下: 实现技巧是在 TextBox 控件的 Style 中使用触发器(Triggers)来显示和隐藏placeholder文本。xmal代码如下&am…...
UiPath Studio 2023.10 Crack
UiPath Studio是一款功能强大且用户友好的集成开发环境 (IDE),专为机器人流程自动化 (RPA) 设计。它由自动化技术领域的领先公司UiPath开发。 以下是 UiPath Studio 的一些主要功能和组件: 图形用户界面 (GUI):UiPath Studio 具有直观且用户友…...
SpringBoot——入门及原理
SpringBoot用来简化Spring应用开发,约定大于配置,去繁从简,是由Pivotal团队提供的全新框架。其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置(有特殊需求可以添加自己的配置覆盖默认配…...
js实现页面滚动时自动切换Sidebar标签,点击标签自动滚动页面
js实现页面滚动时自动切换Sidebar侧边导航标签,点击标签自动滚动页面 <van-sidebar class"sidebar" v-model"activeKey"><van-sidebar-item :title"i.title" click"onChange(i)" v-for"(i,k) in activeList&…...
Failed to load resource: net::ERR_UPLOAD_FILE_CHANGED 谷歌浏览器就会有这个问题 其他的浏览器没有
Failed to load resource: net::ERR_UPLOAD_FILE_CHANGED 10 10: Difficulties in file uploading through all browsers and applications...
微信小程序 prettier 格式化
一、安装prettier插件 二、打开设置 然后再打开setting.json 新增代码 {"editor.formatOnSave": true,"editor.defaultFormatter": "esbenp.prettier-vscode","prettier.documentSelectors": ["**/*.wxml", "**/*.wx…...
SystemVerilog学习 (10)——线程控制
一、概述 在实际硬件中,时序逻辑通过时钟沿来激活,组合逻辑的输出则随着输人的变化而变化。所有这些并发的活动在Verilog 的寄存器传输级上是通过initial和 always块语句、实例化和连续赋值语句来模拟的。为了模拟和检验这些语句块,测试平台使用许多并发执行的线程。在测试平台…...
【开题报告】基于SpringBoot的二手汽车交易平台的设计与实现
1.研究背景 随着社会经济的不断发展,二手汽车交易市场逐渐壮大,二手汽车交易平台作为一种重要的电子商务形式备受关注。本文基于Spring Boot框架,旨在设计与实现一个高效、安全、用户友好的二手汽车交易平台。本文将深入探讨二手汽车市场发展…...
Python 爬虫入门
文章目录 Python 爬虫入门requests 库beautifulsoup4库函数findall(),find()函数get() 爬虫实例 1:抓小说爬虫实例 2:抓豆瓣 top 250 的电影信息后记 Python 爬虫入门 Python 的爬虫功能使得程序员可以快速抓取并分析网页中的信息࿰…...
[ 加密 ] SHA256
SHA256 例程 一般文件的完整性要使用md5或者sha进行完整性校验,这里提供两个函数, intact_update_sha 是计算指定文件SHA值并保存到SHA文件 intact_check_sha 计算文件SHA值并和SHA文件进行对比 编译方法: gcc demo.c -lssl -lcrypto #…...
推荐一个windows上传linux服务器/linux服务器的docker镜像的工具,摆脱docker cp,以及解决常见问题。
Lrzsz,又称为lrz和lsz,是一个用于在Unix、Linux、macOS等操作系统上进行串行文件传输的工具。它支持基于X/Y/ZModem协议的文件传输,能够通过串口或者Telnet/SSH等网络连接进行文件传输。Lrzsz具有传输速度快、可靠性高、易于使用等特点&#…...
《QT从基础到进阶·三十五》QT插件实现侧边工具栏tabBar
tabBar是用QT插件实现的一个dll,对于插件的使用可以参考文章: 《QT从基础到进阶三十三》QT插件开发QtPlugin 源码放在文章末尾 该功能类似侧边工具栏,可以在该标签栏上添加自己开发的界面,实现代码如下: 1、所有功能…...
LLM在教育技术中的应用与优化策略
1. LLM在教育技术领域的应用概述大型语言模型(Large Language Model, LLM)正在深刻改变教育技术的面貌。作为一名长期关注教育技术发展的从业者,我亲眼见证了这项技术从实验室走向课堂的完整历程。在教育场景中,LLM最核心的价值在于其强大的语义理解能力…...
SQL调优三维战法:执行计划×索引策略×监控体系
SQL调优三维战法:执行计划索引策略监控体系 在数据量爆炸式增长的时代,每秒延迟都可能意味着数百万损失。某头部电商平台曾因一个未被发现的索引缺失导致大促期间数据库崩溃,直接损失超2亿营收——这绝非孤例。本文将揭示从金融级交易系统到亿级用户社交平台验证过的SQL优化…...
以为再也见不到那些文件了…” 客户差点哭出来,结果数据全回来了
数据恢复常见误区与故障排查:从文件误删到硬盘异响的技术分析摘要: 在日常使用中,数据丢失常以不同形式出现——系统崩溃无法开机、硬盘发出异响、文件误删后清空回收站、服务器RAID阵列突然离线。许多用户在故障发生时因错误操作导致恢复难度…...
CANN/metadef创建HcomRecordTask
CreateHcomRecordTask 【免费下载链接】metadef Ascend Metadata Definition 项目地址: https://gitcode.com/cann/metadef 函数功能 创建一个Record task,此Task用于唤醒其他流上的与其有相同group_name的Wait Task。 函数原型 static KernelLaunchInfo …...
可见性、有序性、原子性
可见性:当一个线程对共享变量进行修改后,另一个线程可以立即看到该变量修改后的最新值。有序性:程序执行的顺序按照代码的先后顺序执行。原子性:在一次或者多次操作时,要么所有操作都被执行,要么所有操作都…...
XUnity Auto Translator:打破语言壁垒的Unity游戏翻译革命性方案
XUnity Auto Translator:打破语言壁垒的Unity游戏翻译革命性方案 【免费下载链接】XUnity.AutoTranslator 项目地址: https://gitcode.com/gh_mirrors/xu/XUnity.AutoTranslator 你是否曾经遇到过这样的情况:终于等到心仪的Unity游戏发售&#x…...
ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03
ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03ceshi02ceshi03...
除了ChatGPT,SSE还能这么用?用Nginx代理构建一个实时日志仪表盘
实时日志监控新思路:基于Nginx与SSE的高效实践 日志监控一直是开发运维工作中的关键环节。传统的轮询方式不仅效率低下,还增加了服务器负担。今天我要分享的是一种基于Server-Sent Events(SSE)技术的实时日志监控方案,结合Nginx反向代理实现…...
使用Taotoken后我的API调用延迟与稳定性观察记录
🚀 告别海外账号与网络限制!稳定直连全球优质大模型,限时半价接入中。 👉 点击领取海量免费额度 使用Taotoken后我的API调用延迟与稳定性观察记录 作为一名日常重度依赖大模型API进行编程辅助和代码生成的开发者,我最…...
可预测AI:构建可预知性能与安全性的智能系统框架
1. 项目概述:从“黑盒”到“白盒”的智能进化“可预测AI”这个概念,最近几年在工业界和学术界的讨论热度越来越高。它直指当前主流人工智能应用,尤其是深度学习模型的一个核心痛点:不可预测性。我们训练了一个模型,在测…...
