Home > database >  The same data, why varchar2 (4000) than varchar2 (1000) produce big redo?
The same data, why varchar2 (4000) than varchar2 (1000) produce big redo?

Time:09-15

As title, see the article on the net, to do the test, true don't know why this is,

1, create two tables, t1 with varchar2 (4000), t2 with varchar2 (1000)
The create table t1 (x number, x2 varchar2 (4000), the x3 varchar2 (4000)) SEGMENT CREATION IMMEDIATE;
The create table t2 (x number, x2 varchar2 (1000), the x3 varchar2 (1000)) SEGMENT CREATION IMMEDIATE;

2, to insert the same data in the table
Insert into t1 select level, rpad (', 100, ' '), rpad (' a ', 100, 'a') from dual connect by level & lt; E5=1;
Insert into t2 select level, rpad (', 100, ' '), rpad (' a ', 100, 'a') from dual connect by level & lt; E5=1;

3, open the autotrace
SQL> Insert into t1 select level, rpad (', 100, ' '), rpad (' a ', 100, 'a') from dual connect by level & lt; E5=1;

100000 rows created.


Execution Plan
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Plan the hash value: 1236776825

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
| | Id Operation | Name | Rows | Cost (% CPU) | Time |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
| | 0 INSERT STATEMENT | | 1 | 2 (0) | 00:00:01 |
| | 1 LOAD TABLE but | T1 | | | |
2 | | * CONNECT BY WITHOUT FILTERING | | | | |
| 2 | 3 | FAST DUAL | | 1 (0) | 00:00:01 |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The Predicate Information (identified by operation id) :
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

2 - filter (LEVEL<=1 e5)


The Statistics
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
48 recursive calls
112998 db block gets
5588 consistent gets
Physical reads 0
45758768 redo size
838 bytes sent via SQL * Net to client
860 bytes received via SQL * Net from client
3 the SQL * Net roundtrips to/from the client
2 sorts (memory)
0 sorts (disk)
100000 rows processed

=================================================================

SQL> Insert into t2 select level, rpad (', 100, ' '), rpad (' a ', 100, 'a') from dual connect by level & lt; E5=1;

100000 rows created.

Execution Plan
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Plan the hash value: 1236776825

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
| | Id Operation | Name | Rows | Cost (% CPU) | Time |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
| | 0 INSERT STATEMENT | | 1 | 2 (0) | 00:00:01 |
| | 1 LOAD TABLE but | T2 | | | |
2 | | * CONNECT BY WITHOUT FILTERING | | | | |
| 2 | 3 | FAST DUAL | | 1 (0) | 00:00:01 |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The Predicate Information (identified by operation id) :
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

2 - filter (LEVEL<=1 e5)


The Statistics
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
43 recursive calls
16829 db block gets
6660 consistent gets
Physical reads 0
23691740 redo size
840 bytes sent via SQL * Net to client
860 bytes received via SQL * Net from client
3 the SQL * Net roundtrips to/from the client
2 sorts (memory)
0 sorts (disk)
100000 rows processed

=====================================================================
4, you can see the t1 redo than t2 produced more redo nearly doubled, is this why?



CodePudding user response:

It's fun, the design of the length of varchar2 seems to also cannot too along with the gender,
Two inserts, the former current reading is greater than the latter, indeed, it seems, Oracle, although there is no use of this field is 4000 bytes of space, but the distribution in advance in the block, for future update, so you need to read more blocks to place the same number of records,

CodePudding user response:

reference 1st floor minsic78 response:
this interesting, varchar2 length design seems to also cannot too along with the gender,
Two inserts, the former current reading is greater than the latter, indeed, it seems, Oracle, although there is no use of this field is 4000 bytes of space, but the distribution in advance in the block, for future update, so you need to read more blocks to place the same number of records,


Thank you master, but I still have a problem, if it is assigned in advance, the 4000 bytes occupied block should not be more than 1000 bytes, but the block is 2944, the two tables?
What's why block, 2944, 4000 bytes will have 112998 db block gets 1000 bytes will have 16829 db block gets? More obvious than block table?

SEGMENT_NAME BLOCKS
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
T1 2944
T2 2944

CodePudding user response:

So soon face
  • Related