從Oracle的SGA的構成來看,它是推崇使用 參數綁定的。使用參數綁定可以有效的使用Share Pool,對已經緩存的SQL不用再硬解析,能明顯的提高性能。 具體實踐如下:SQL>create table test (a number(10)); 再創建一個存儲過程:create or replace PRocedure p_test is i number(10); begin i := 0; while i <= 100000 loop execute immediate ' insert into test values (' to_char(i) ')'; i := i + 1; end loop; commit;end p_test;先測試沒有使用參數綁定的:運行 p_test 后,用時91.111秒再創建一個使用參數綁定的:create or replace procedure p_test is i number(10); begin i := 0; while i <= 100000 loop execute immediate ' insert into test values (:a)' using i; i := i + 1; end loop; commit;end p_test;運行 p_test 后,用時55.099秒.從上面的運行時間可以看出,兩者性相差 39.525%,可見,用不用參數綁定在性能上相差是比較大的。 Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1416644