A problem encountered in work, we show page in a data loading too slow, because the show is to get data from view, but the view is more complex structure, the use of multi-table related data from multiple tables obtained. Starting with the thinking of ways to optimize the view and table view used. However, due to the complex structure, after optimization or slow, such as using a query order by more than a hundred seconds of time, this is certainly not acceptable. Only for ways and decided to delete the database table data using regular tasks to the timing, the new table data, it simply is to update the data. But first contact, or spend some time.
code show as below:
- create a table V_TEST, data structures and the same view to the CREATE TABLE V_TEST the AS the SELECT * the FROM the TEST; - defined regular tasks SCIENTIFIC_JOB, for refreshing data DECLARE TEST_JOB Number; the BEGIN DBMS_JOB.SUBMIT ( the JOB => TEST_JOB, - Task the name of the WHAT => ' DELETE the FROM V_TEST; INSERT INTO V_TEST the SELECT * the FROM the TEST; COMMIT; ' , - the stored procedure name or SQL statements to be executed NEXT_DATE => SYSDATE, - the initial execution time - the immediate implementation INTERVAL => ' TRUNC (+ SYSDATE. 1) +9/24 ' - nine o'clock every morning ); a COMMIT; End; - pay attention! ! ! TEST_JOB here to find out the ID, will be used below. LOG_USER found for the current database user ID is the task ID the SELECT * from DBA_JOBS; - mission 1183 is to check out the above ID needs to be replaced own the begin dbms_job.run ( 1183 ); End; timed tasks related to the query: - Display the current time as a remote server, and the local time will be different SELECT TO_CHAR (SYSDATE, ' YYYY-mm-dd HH24: mi the: SS ' ) from Dual; - see all scheduled tasks SELECT * from DBA_JOBS; - - scheduling tasks View executing the SELECT * from DBA_JOBS_RUNNING; -Delete a task of 1183 is to query task ID the begin DBMS_JOB.REMOVE ( 1183 ); End;
Long time no post to a blog, and recently a little busy. Refueling 0.0