DB2面向OLTP环境的物理数据库设计:查询设计
在最基本的层面,包括选择、插入、更新和删除在内的 SQL 操作是应用程序与 DB2 数据库进行交互的方式。应用程序的总体性能和体验受到该应用程序所用的 SQL 操作的影响。 设计、维护、监视和调优 SQL 查询的完整处理超出了本文的范围。然而,我们从较高层次概
在最基本的层面,包括选择、插入、更新和删除在内的 SQL 操作是应用程序与 DB2 进行交互的方式。应用程序的总体性能和体验受到该应用程序所用的 SQL 操作的影响。 设计、维护、监视和调优 SQL 查询的完整处理超出了本文的范围。然而,我们从较高层次概述了查询设计的工具和一般准则,因为查询设计和物理设计彼此密切相关。
大多数物理数据库设计的特征对 SQL 语句并不明显,但为了更好地使用 DB2 特性,在编写查询时需要考虑到数据库的物理特征,如索引。例如,使用范围分区表时,选择查询即使没有包含谓词和范围分区键,也仍然可以正常工作。然而,它可能没有分区消除的性能优势。 另一方面,如果由于数据增长或其他任何原因,导致某个 SQL 操作无法满足业务服务水平协议,那么可能必须修改物理数据库设计。物理数据库设计变更的示例包括:增加索引、将常规表转换为范围分区表,或更改缓冲池的大小或关联,以达到预期的性能目标。
OLTP 工作负载查询
OLTP 工作负载中的查询通常较短,涉及极少的表,并返回较小的结果集。不过,相比其他类型的工作负载,在 OLTP 工作负载中有更多并发查询。 对于 OLTP 工作负载,设计可以快速返回结果的查询对于获得良好的性能是至关重要的。 此外,考虑到 OLTP 工作负载系统中一般有大量并发运行的查询。死锁、因超时等待锁定而回滚,甚至“死机”之类的事务可能会经常发生。导致较少的死锁和回滚的查询设计可以使查询性能有明显差异。
OLTP 应用程序对于使用范围分隔谓词的索引扫描是很好的候选者,因为它们往往只返回几个行,具有能够对一个键列使用平等谓词的资格。如果您的 OLTP 单查询使用表扫描,您可能想对解释设施 (explain facility) 数据进行分析,以确定不使用索引扫描的原因。
隔离级别
DB2 数据库管理器支持以下四种类型的隔离级别。它们按对性能的影响以降序排列,但在访问和更新数据时,它们需要的维护则是以升序排列的。
可重复读 (RR)
RR 隔离级别将锁定应用程序在某个工作单元内引用的所有行。使用此隔离级别,丢失更新、访问未提交的数据和幻像行 (phantom row) 是不可能的。
读稳定性 (RS)
RS 隔离级别只锁定应用程序在工作单元内检索的那些行。
游标稳定性 (CS)
CS 隔离级别锁定应用程序的事务所访问的任何行,同时将游标定位到该行上。 未提交的读 (UR) UR 隔离级别允许应用程序访问其他事务未提交的变更。未提交读对只读和可更新游标的工作方式不同。
应用程序死锁
死锁影响数据库系统的性能。当死锁发生时,数据库管理器会选出要停止或回滚哪些事务(受害者)。这种影响会导致用户获得不好的体验。如果数据库配置参数设置不正确,那么用户可能会遇到停留在死锁状态的情况,最终可能需要数据库管理员来解决死锁。
当您发出包含 WITH RELEASE 子句的 CLOSE CURSOR 语句来关闭游标时,数据库管理器会尝试释放游标持有的所有读锁。表读锁是 IS、S 和 U 表锁。行读锁是 S、NS 和 U 行锁。块读锁是 IS、S 和 U 块锁。 WITH RELEASE 子句对在 CS 或 UR 隔离级别下操作的游标没有影响。对于在 RS 或 RR 隔离级别下操作的游标,WITH RELEASE 子句取消了这些隔离级别的部分保证。具体来说,一个 RS 游标可能会遇到不可重复读现象,一个 RR 游标可能会遇到一个不可重复读或幻读。
如果在关闭原本在 RR 或 RS 隔离级别下操作的游标后,您通过 WITH RELEASE 子句重新打开它,那么您会获得新的读锁。 在某些情况下,在结果集关闭后会仍然保持锁定,并且提交事务。如果在发出 COMMIT 语句之前关闭 CURSOR WITH HOLD,可以确保锁定被释放。即使在使用动态 SQL 的未提交读应用程序中,也会获得目录锁。要释放目录锁,请显式发出 COMMIT 语句。
LOCK TABLE 语句锁定整个表。只锁定在 LOCK TABLE 语句中指定的表,没有锁定指定表的父表和依赖表。直到提交或回滚工作单元,才会释放锁定。您可以使用该语句防止锁升级。您必须确定是否锁定整个表及相关表是必要的,然后才能在并发性和性能方面实现想要的结果。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.

LaravelEloquent Model Retrieval: Easily obtaining database data EloquentORM provides a concise and easy-to-understand way to operate the database. This article will introduce various Eloquent model search techniques in detail to help you obtain data from the database efficiently. 1. Get all records. Use the all() method to get all records in the database table: useApp\Models\Post;$posts=Post::all(); This will return a collection. You can access data using foreach loop or other collection methods: foreach($postsas$post){echo$post->

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.
