我有一个脚本
SQL script: alter table xx_vms.es_lot_updates modify (routing_list varchar2(1000));
该列之前的大小是 255。现在我将其大小增加到 1000。但是在这个表中,routing_list 列经常是 NULL。有时,它是有价值的。
此列的增量大小是否会导致性能问题?我很困惑!请帮忙。谢谢。
不,没有性能问题。您所做的只是允许在该列中插入更大的文本字符串。请记住,您应该始终尽可能严格地限制您希望在表格中允许的内容,您可以自由地将列设置为您需要的大小。(varchar2 最多 4000 字节)
这取决于。具有 varchar2(1000) 的表使用更多的数据库块进行存储,因此全表扫描可能会更昂贵,因为您要读取更多块。这是一个简单的测试:
17:48:25 HR@sandbox> create table c1000 (txt varchar2(1000));
Table created.
Elapsed: 00:00:00.21
17:48:37 HR@sandbox> create table c255 (txt varchar2(255));
Table created.
Elapsed: 00:00:00.03
-- for this test we assume that only 10% of columns are filled with data
17:50:21 HR@sandbox> ed
Wrote file S:\spool\sandbox\BUFFER_HR_32.sql
1 insert into c255
2 select decode(mod(rownum,10), 0, lpad('x', 255,'x')) from dual
3* connect by rownum <= 1e5
17:50:24 HR@sandbox> /
100000 rows created.
Elapsed: 00:00:01.26
17:50:47 HR@sandbox> ed
Wrote file S:\spool\sandbox\BUFFER_HR_32.sql
1 insert into c1000
2 select decode(mod(rownum,10), 0, lpad('x', 1000,'x')) from dual
3* connect by rownum <= 1e5
17:50:51 HR@sandbox> /
100000 rows created.
Elapsed: 00:00:01.45
17:50:52 HR@sandbox> commit;
Commit complete.
Elapsed: 00:00:00.01
17:51:20 HR@sandbox> select table_name, blocks from user_tables where table_name in ('C255', 'C1000');
TABLE_NAME BLOCKS
------------------------------ ----------
C1000 1756
C255 622
Elapsed: 00:00:00.20
17:53:28 HR@sandbox> set autotrace traceonly statistics
17:53:37 HR@sandbox> select * from c1000;
100000 rows selected.
Elapsed: 00:00:01.30
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
1901 consistent gets
1694 physical reads
0 redo size
10586458 bytes sent via SQL*Net to client
2552 bytes received via SQL*Net from client
201 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
100000 rows processed
17:53:50 HR@sandbox> select * from c255;
100000 rows selected.
Elapsed: 00:00:00.63
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
825 consistent gets
295 physical reads
0 redo size
3107206 bytes sent via SQL*Net to client
2552 bytes received via SQL*Net from client
201 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
100000 rows processed
看consistent gets
统计。与. c1000
_c255
但是,如果您使用主键仅选择几行,我认为您不会注意到显着差异。
不,它与性能无关,varchar2 的最大大小为 4000。
一旦你改变了表,请记住编译所有依赖项,因为它们将是无效的,例如
程序和包