Skip to content

Instantly share code, notes, and snippets.

@mujahidk
Created January 29, 2019 18:24
Show Gist options
  • Save mujahidk/cf5ede87f44891a9e4fb858d0836dad0 to your computer and use it in GitHub Desktop.
Save mujahidk/cf5ede87f44891a9e4fb858d0836dad0 to your computer and use it in GitHub Desktop.
Oracle PL/SQL block to run a query multiple times and measure time.
SET TIMING ON
DECLARE
START_TIME PLS_INTEGER;
COUNT_ROW NUMBER;
BEGIN
FOR I IN 1..10 LOOP
START_TIME := DBMS_UTILITY.GET_TIME();
SELECT COUNT(*) INTO COUNT_ROW FROM (SELECT * FROM PERSON ORDER BY LASTNAME ASC) WHERE ROWNUM <= 50;
DBMS_OUTPUT.PUT_LINE('Selected ' || COUNT_ROW || ' in ' || (DBMS_UTILITY.GET_TIME() - START_TIME) || '/100 seconds');
END LOOP;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment