CREATE OR REPLACE PROCEDURE P_TESTTABLE IS
v_objtab TY_OBJ_LST;
v_bdate TIMESTAMP;
v_edate TIMESTAMP;
v_number NUMBER;
v_tmptime NUMBER;
v_funtime NUMBER;
v_phytime NUMBER;
BEGIN
v_objtab := TY_OBJ_LST();
DELETE FROM tmp_obj;
FOR i IN 1..90000 LOOP
INSERT INTO tmp_obj VALUES(i, i);
v_objtab.EXTEND;
v_objtab(i) := ty_obj(to_char(i), to_char(i));
END LOOP;
FOR i IN 1..100 LOOP
dbms_output.put_line('');
dbms_output.put_line('select from temp table ...');
v_bdate := current_timestamp();
-- dbms_output.put_line(v_bdate);
SELECT COUNT(*) INTO v_number FROM tmp_obj;
-- dbms_output.put_line(v_number || ' rows selected!');
v_edate := current_timestamp();
-- dbms_output.put_line(v_edate);
v_tmptime := extract( day from (v_edate-v_bdate) )*24*60*60+
extract( hour from (v_edate-v_bdate) )*60*60+
extract( minute from (v_edate-v_bdate) )*60+
extract( second from (v_edate-v_bdate));
dbms_output.put_line('consumed: '||to_char(v_tmptime)||' seconds');
dbms_output.put_line('');
dbms_output.put_line('select from function table ...');
v_bdate := current_timestamp();
-- dbms_output.put_line(v_bdate);
SELECT COUNT(*) INTO v_number FROM TABLE(CAST(v_objtab AS TY_OBJ_LST));
-- dbms_output.put_line(v_number || ' rows selected!');
v_edate := current_timestamp();
-- dbms_output.put_line(v_edate);
v_funtime := extract( day from (v_edate-v_bdate) )*24*60*60+
extract( hour from (v_edate-v_bdate) )*60*60+
extract( minute from (v_edate-v_bdate) )*60+
extract( second from (v_edate-v_bdate));
dbms_output.put_line('consumed: '||to_char(v_funtime)||' seconds');
dbms_output.put_line('');
dbms_output.put_line('select from physical table ...');
v_bdate := current_timestamp();
-- dbms_output.put_line(v_bdate);
SELECT COUNT(*) INTO v_number FROM phy_obj;
-- dbms_output.put_line(v_number || ' rows selected!');
v_edate := current_timestamp();
-- dbms_output.put_line(v_edate);
v_phytime := extract( day from (v_edate-v_bdate) )*24*60*60+
extract( hour from (v_edate-v_bdate) )*60*60+
extract( minute from (v_edate-v_bdate) )*60+
extract( second from (v_edate-v_bdate));
dbms_output.put_line('consumed: '||to_char(v_phytime)||' seconds');
INSERT INTO stat_tables (tid , idate , tmptime , funtime , phytime )
VALUES (stat_id_seq.nextval, SYSDATE, v_tmptime, v_funtime, v_phytime);
END LOOP;
COMMIT;
END P_TESTTABLE;