パフォーマンスに違いはありません。また、2の累乗のため、隠れた最適化は行われません。
物事の保存方法に違いをもたらす唯一のものは、実際のです。 データ。 VARCHAR2(2000)に格納されている100文字 列は、VARCHAR2(500)に格納されている100文字とまったく同じ方法で格納されます。 列。
長さをビジネス上の制約と考えてください 、データ型の一部としてではありません。長さに関する決定を左右する唯一のことは、そこに配置されるデータに関するビジネス上の制約です。
編集 :長さがする唯一の状況 違いを生むのは、その列にインデックスが必要な場合です。古いバージョン(<10)にはキーの長さに制限があり、インデックスの作成時にチェックされていました。
Oracle 11では可能ですが、4000文字の値にインデックスを付けるのは賢明な選択ではないかもしれません。
編集2 :
だから私は興味があり、簡単なテストを設定しました:
create table narrow (id varchar(40));
create table wide (id varchar(4000));
次に、両方のテーブルに40'X'で構成される文字列を入力しました。ストレージ間に実際に(実質的な)違いがあった場合、データを取得するときにこれが何らかの形で表示されるはずですよね?
どちらのテーブルにも正確に1048576行があります。
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set autotrace traceonly statistics
SQL> select count(*) from wide;
Statistics
----------------------------------------------------------
0 recursive calls
1 db block gets
6833 consistent gets
0 physical reads
0 redo size
349 bytes sent via SQL*Net to client
472 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select count(*) from narrow;
Statistics
----------------------------------------------------------
0 recursive calls
1 db block gets
6833 consistent gets
0 physical reads
0 redo size
349 bytes sent via SQL*Net to client
472 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
したがって、両方のテーブルの全表スキャンはまったく同じでした。では、実際にデータを選択するとどうなるでしょうか。
SQL> select * from wide;
1048576 rows selected.
Statistics
----------------------------------------------------------
4 recursive calls
2 db block gets
76497 consistent gets
0 physical reads
0 redo size
54386472 bytes sent via SQL*Net to client
769427 bytes received via SQL*Net from client
69907 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1048576 rows processed
SQL> select * from narrow;
1048576 rows selected.
Statistics
----------------------------------------------------------
4 recursive calls
2 db block gets
76485 consistent gets
0 physical reads
0 redo size
54386472 bytes sent via SQL*Net to client
769427 bytes received via SQL*Net from client
69907 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1048576 rows processed
SQL>
一貫性のある取得にはわずかな違いがありますが、それはキャッシュが原因である可能性があります。