Oracle row migration行迁移
问题描述:今天又遇到一小问题:在某个表新添加二个字段后,查询速度明显缓慢。 大家讨论怀疑是行迁移导致, 试了move 一下就ok
问题描述:今天又遇到一小问题:在某个表新添加二个字段后,查询速度明显缓慢。
大家讨论怀疑是行迁移导致, 试了move 一下就ok
行迁移的影响
如果你通过一个索引来读这一行,索引会指向原来的块,那个块再指向这个新块。要得到具体的行数据,一般并不是执行两个左右的I/O 就可以得到行数据。单独来看,这不是大问题,甚至根本注意不到。不过,如果这种行所占的比例相当大,而且有大量用户在访问这些行,你就会注意到这种副作用了。访问这些数据的速度开始变慢(额外的I/O 以及与I/O 相关的闩定都会增加访问时间),缓冲区缓存的效率开始下降(需要缓存两个块,而如果行没有迁移就只需要缓存一个块)
二种情况
1行链接产生在第一次插入数据的时候如果一个block不能存放一行记录的情况下。这种情况下,Oracle将使用链接一个或者多个在这个段中保留的block存储这一行记录,行链接比较容易发生在比较大的行上,例如行上有LONG、LONG RAW、LOB等数据类型的字段,这种时候行链接是不可避免的会产生的。
2当一行记录初始插入的时候事可以存储在一个block中的,由于更新操作导致行长增加了,而block的自由空间已经完全满了,这个时候就产生了行迁移。在这种情况下,Oracle将会迁移整行数据到一个新的block中(假设一个block中可以存储下整行数据),Oracle会保留被迁移行的原始指针指向新的存放行数据的block,这就意味着被迁移行的ROW ID是不会改变的。
二个参数
user_tables 中的CHAIN_CNT
--行迁移的 数量
Number of rows in the table that are chained from one data block to another,
or which have migrated to a new block, requiring a link to preserve the old ROWID
--行数
NUM_ROWS
例子:
analyze table t compute statistics;
Table analyzed.
SQL> select table_name,num_rows,CHAIN_CNT from user_tables where table_name='T';
TABLE_NAME NUM_ROWS CHAIN_CNT
------------------------------ ---------- ----------
T 41616 3908
SQL> alter table t move ;
Table altered.
SQL> analyze table t compute statistics;
Table analyzed.
SQL> select table_name,num_rows,CHAIN_CNT from user_tables where table_name='T';
TABLE_NAME NUM_ROWS CHAIN_CNT
------------------------------ ---------- ----------
T 41616 0

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.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

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.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

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.

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.
