组合索引和单列索引效率对比

  • Post author:
  • Post category:其他


SQL> create table test(object_id NUMBER,object_name varchar2(10));

Table created.

SQL> begin
  2  for i in 1 .. 1000000
  3  loop
  4  insert into test values (1,'TEST');
  5  end loop; 
  6  end;
  7  /

PL/SQL procedure successfully completed.


SQL> begin
  2  for i in  1 .. 300
  3  loop
  4  insert into test values (2,'TEST2');
  5  end loop;
  6  end;
  7  /

PL/SQL procedure successfully completed.

SQL> begin
  2  for i in  1 .. 49700
  3  loop
  4  insert into test values (2,i||'TEST2');
  5  end loop;
  6  end;
  7  /

SQL> select count(*), object_id from test group by object_id;

  COUNT(*)  OBJECT_ID
---------- ----------
   1000000	    1
     50000	    2



SQL>  select count(*) from test where object_name='TEST2' and object_id=2;

  COUNT(*)
----------
       300

SQL> select count(*) from test where object_name<>'TEST2&#



版权声明:本文为zhaoyangjian724原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。