ORACLE性能测试

ORACLE插入:


CREATE OR REPLACE PROCEDURE TEST
IS

I INTEGER;
STARTTIME TIMESTAMP;
ENDTIME TIMESTAMP;

BEGIN
  DELETE FROM PERSON;
  COMMIT;

  STARTTIME := SYSTIMESTAMP;
  FOR I IN 1..100000 LOOP
    INSERT INTO PERSON VALUES('JW');
  END LOOP;  
  COMMIT;

  ENDTIME := SYSTIMESTAMP;  
  DBMS_OUTPUT.PUT_LINE(ENDTIME - STARTTIME);
END;
/

CREATE OR REPLACE PROCEDURE TEST2
IS

I INTEGER;
STARTTIME TIMESTAMP;
ENDTIME TIMESTAMP;

BEGIN
  DELETE FROM PERSON;
  COMMIT;

  STARTTIME := SYSTIMESTAMP;
  FOR I IN 1..100000 LOOP
    INSERT INTO PERSON VALUES('JW');
    COMMIT;
  END LOOP;  

  ENDTIME := SYSTIMESTAMP;  
  DBMS_OUTPUT.PUT_LINE(ENDTIME - STARTTIME);
END;
/


BEGIN
  TEST;
  TEST;
  TEST;
  TEST2;
  TEST2;
  TEST2;
END;

结果1:
+000000000 00:00:09.266000000
+000000000 00:00:07.448000000
+000000000 00:00:06.704000000
+000000000 00:00:15.845000000
+000000000 00:00:15.197000000
+000000000 00:00:15.798000000
结果2:
+000000000 00:00:08.857000000
+000000000 00:00:05.875000000
+000000000 00:00:08.970000000
+000000000 00:00:35.106000000
+000000000 00:00:26.362000000
+000000000 00:00:20.907000000

ORACLE查询:

CREATE OR REPLACE PROCEDURE TEST3
AS
ZERO INT;
CURSOR CUR IS SELECT * FROM PERSON WHERE ROWNUM <= 100000;
CUR_ROW PERSON%ROWTYPE;
STARTTIME TIMESTAMP;
ENDTIME TIMESTAMP;
BEGIN
  STARTTIME := SYSTIMESTAMP;
  --FETCH CUR INTO CUR_ROW;
  FOR CUR_ROW IN CUR LOOP
    ZERO := 0;
  END LOOP;
  ENDTIME := SYSTIMESTAMP;
  DBMS_OUTPUT.PUT_LINE(ENDTIME - STARTTIME);
END;
/

BEGIN
  TEST3;
END;

结果1:
+000000000 00:00:00.109000000

结果2:
+000000000 00:00:00.125000000

你可能感兴趣的:(数据库)