đề thi quản trị cơ sở dữ liệu phân tán 5

109 752 0
đề thi quản trị cơ sở dữ liệu phân tán 5

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CHƯƠNG II: QUẢN LÝ DỮ LIỆU TRONG CSDL PHÂN TÁN (số tiết ) • Lập mục 2.1.1 Tổng quan ( Chỉ mục gì?Tại lập mục) Là cấu trúc tùy chọn cho bảng hay bó liệu Nó tăng tốc trình làm việc với bảng với truy vấn đơn giản Ta có hiển thị thao tác bảng nhanh Các yếu tố • Nhằm cải thiện hiệu • Có thể tạo hay nhiều cột • Cập nhật tự động(khi thêm/xóa) • Có thể lập, hủy mục mà không ảnh hưởng đến bảng Các loại mục • • B-tree indexes: the default and the most common B-tree cluster indexes: defined specifically for cluster • Hash cluster indexes: defined specifically for a hash cluster • Global and local indexes: relate to partitioned tables and indexes • Reverse key indexes: most useful for Oracle Real Application Clusters applications • Bitmap indexes: compact; work best for columns with a small set of values • Function-based indexes: contain the precomputed value of a function/expression • Domain indexes: specific to an application or cartridge • Chi tiết (Các kiểu Index: B-tree bitmap) Cấu trúc B-tree: B-tree có giá trị lưu cân cho phép tìm kiếm nhị phân nhanh o Root-Các nhánh(nhiều)-Các với Index—Keycolumn length—Key column value—ROWID o Tìm thêm nguyên lý giá trị • Cấu trúc Bitmap: Bitmap: có bitmap cho cac giá tri liệu, đối sánh tìm kiếm Có tác dụng cột có giá trị nhỏ(VD: Nam Nũ) o Giá trị khóa(cặp độ dài-giá trị=giá trị khóa)—Start ROWID—End ROWID—bitmap segment o Nguyên lý: Dùng B-Tree để định vị segment bitmap cho Các tùy chọn Index - Unique index - Sắp xếp tăng( hay giảm) - Index khóa đảo ngược (các giá trị byte đảo) - Index theo Khóa phức hợp: nhiều cột - Index dựa hàm - Index nén có nhiều khóa lặp lại == Chỉ mục hoạt động Công nghệ Xử lý C/S Ưu điểm Linh hoạt, liên tác, quy mô Xử lý CSDL song song CSDL PT Tăng tốc độ, mạnh, quy mô cho cải thiện hiệu dự đoán Điều khiển cục liệu, cải thiện hiệu năng, giảm giá thành truyền thông, tăng độ tin cậy Scale up tăng cường • • • • • Managing Database Links Viewing Information About Database Links Creating Location Transparency Managing Statement Transparency Managing a Distributed Database: Scenarios Định nghĩa Các loại Nhược điểm Tính phức tạp, giá thành phát triển cao, toán liên tác Báì toán liên tác, giá thành cao Tính phức tạp cao, bổ sung yếu tố an ninh Những vấn đề xây dựng sử dụng mục • Tạo mục  Tạo mục sau có liệu bảng o Chỉ mục yêu cầu không gian nhớ không lớn  Lập mục bảng cột nên lập mục o o o Xử lý liêu( -9.99 * power(10,125) Lúc thay : WHERE COL_X IS NOT NULL  Các cột không nên chọn làm mục: o o Có nhiều giá trị null cột mà không tìm kiếm giá trị not null Không lập mục cho cột LONG and LONG RAW Kích thứơc lối vào mục đơn không vượt nửa không gian có sẵn data block  Lập thứ tự cột mục với hiệu Thứ tự cột lập mục quan trọng, nên lập mục cho cột hay dùng Nếu lập cho col1,col2,col3 có tác dụng col1, sau đến col2 làm với col2, col3  Hạn chế số lượng mục cho bảng: (Khi thêm hủy hàng, sửa nội dung hàng cập nhật mục)  Cần cân nhắc việc lập mục Lợi cột lập mục read-only o o o o Hủy mục không cần thiết Nếu không tăng tốc truy vấn, bảng nhỏ Truy vấn không dùng index Index phải xóa trước phải rebuit  Dự đoán kích thứơc thiết lập thâm số nhớ Dự đoán không gian bảng, kích thước index, undo Làm cho index bố trí liên tục, tiết kiệm thời gian IO Nên có kích thước nửa datablock  Đặc tả không gian bảng cho mục Nếu dùng chung không gian bảng thuận tiện hơn, đảm bảo ứng dụng giành sẵn(online) Nếu dùng khác đĩa tốt khó khăn offline, việc tham chiếu khó khăn  Xem xét việc song song tạo • • mục Có thể song song việc tạo mục song song việc tạo bảng, việc thực nhanh Tham số nhớ dùng tách rời cho tiến trình server Giá trị khởi đầu INITIAL 5M song song 12 cột cần 60M tạo mục  Xem xét tạo mục với NOLOGGING Tạo index phát sinh ghi undo tối thiểu cách đặc tả NOLOGGING câu lệnh CREATE INDEX (nếu dùng NOLOGGING nên backup sau tạo index) Khi dùng NOLOGGING có lợi • • Tiết kiệm không gian file redo Giảm thời gian tạo index • Hiệu cao song song việc tạo index lớn  Xem xét giá thành lợi nhuận gắn kết hay dựng lại mục Khi index lớn bị phân mảnh Để loại bỏ rebuid hay coalesie Cần cân nhắc trọng số dùng Xem bảng Table 16-1 To Rebuild or Coalesce That Is the Question Rebuild Index Coalesce Index Chuyển nhanh liệu đến tablespace khác Không thể chuyển index đến tablespace khác Giá thành cao Giá thành thấp: không yêu cầu không gian đĩa nhiều Tạo mới, thu ngắn độ cao cần Gắn kết khối nhánh Cho phép thay đổi nhanh tham số nhớ Giải phóng nhanh khối cho việc sử không gian bảng mà hủy index dụng nguyên thủy Khi dùng index khối nhị phân cần nhanh cho việc dùng lại, dùng lệnh để móc nối khối với nhau: ALTER INDEX vmoore COALESCE; Figure 16-1 minh họa ALTER INDEX COALESCE index vmoore Trước thực thao tác, khối đầu đầy 50% Như ta có hội giảm nhỏ phân mảnh lấp đầy khối đầu giải phóng khối thứ hai Figure 16-1 Coalescing Indexes  Xem xét giá thành trước vô hiệu hóa hay hủy ràng buộc Vì khóa unique quan hệ với index nên cần cân nhắc hủy hay vô hiệu ràng buộc UNIQUE or PRIMARY KEY Nếu ràng buộc lớn tkiệm thời gian bỏ lại hiệu lực UNIQUE or PRIMARY KEY hủy Cần có tùy chọn tường minh cho ràng buộc UNIQUE or PRIMARY KEY 2.1.2.2 Quản trị mục a Tạo mục Để tạo index Tối thiểu cần điều kiện • • Bảng hay bó index lược đồ Có quyền INDEX bảng index • Có quyền hệ thống CREATE ANY INDEX Để tạo index lược đồ khác, tối thiểu cần • • Có quyền hệ thống CREATE ANY INDEX Người sử hữu lược đồ khác có quota cho không gian bảng để ràng buộc index phân chương index hay quyền hệ thống UNLIMITED TABLESPACE  Tạo mục tường minh Có thể tạo mục tường minh(ngoài ràng buộc toàn vẹn) dùng câu lệnh SQL CREATE INDEX Vd: tao index tên emp_ename cho cột ename bảng emp CREATE INDEX emp_ename ON emp(ename) TABLESPACE users STORAGE (INITIAL 20K NEXT 20k PCTINCREASE 75); Có vài thiết lập nhớ đặc tả tường minh cho index Nếu không ( INITIAL NEXT) dùng mặc định hay không gian bảng đặc tả sử dụng tự động  Tạo mục tường minh đơn nhất(unique) Khái niệm unique non-unique Dùng CREATE UNIQUE INDEX để tạo index UNIQUE: CREATE UNIQUE INDEX dept_unique_index ON dept (dname) TABLESPACE indx; Thêm nữa, đinh nghĩa ràng buộc toàn vẹn UNIQUE cột yêu cầu CSDL buộc ràng buộc toàn vẹn UNIQUE định nghĩa tự động index unique khóa unique Tuy nhiên index tồn cho hiệu truy vấn kể index unique nên tạo tường minh • Tạo mục liên kết với ràng buộc CSDL Oracle buộc khóa UNIQUE hay ràng buộc toàn vẹn PRIMARY KEY bảng tạo một index unique hay khóa primary Index tự động tạo CSDL ràng buộc cho phép Không hành động yêu cầu công bố CREATE TABLE hay ALTER TABLE để tạo index, ta đặc tả USING INDEX để điều khiển qua việc tạo bảng Điều bao gồm ràng buộc định nghĩa cho phép định nghái không cho phép Để cho phép ràng buộc UNIQUE hay PRIMARY KEY, phải tạo index liên quan, người sở hữu bảng phải có quotacho không gian bảng hướng đến index hay quyền hệ thống UNLIMITED TABLESPACE Index liên quan đến ràng buộc thường lấy tên ràng buộc tùy chọn đặc tả khác B1: Đặc tả tùy chọn lưu trữ cho mục kết nối với ràng buộc(unique hay Primary key)-Mệnh đề ENABLE PRIMARY KEY/UNIQUE Tùy chọn ràng buộc UNIQUE and PRIMARY KEY Sử dụng mệnh đề USING INDEX Ví dụ lệnh tạo bảng sau CREATE TABLE cho phép ràng buộc PRIMARY KEY đặc tả tùy chọn với mục: CREATE TABLE emp ( empno NUMBER(5) PRIMARY KEY, age INTEGER) ENABLE PRIMARY KEY USING INDEX TABLESPACE users; B2: Đặc tả mục liên kết với ràng buộc Nếu cần nhiều mục kết nối với ràng buộc UNIQUE and PRIMARY KEY CSDL cho phép: • Đặc tả ràng buộc có mà CSDL dùng để bắt theo ràng buộc • Đặc tả câu lệnh CREATE INDEX mà CSDL dùng để tạo mục bắt theo ràng buộc Lúc dùng mệnh đề USING INDEX (trong lệnh) VD: Example 1: (tạo bảng a có a1 la khóa dùng mục theo ràng buộc a(a1) ) CREATE TABLE a ( a1 INT PRIMARY KEY USING INDEX (create index on a (a1))); Example 2: (tạo bảng b có b1,b2 ràng buộc bu1 unique dùng mục bi theo b1,b2 ràng buộc bu2 unique theo b1,b2 dùng index bi) CREATE TABLE b( b1 INT, b2 INT, CONSTRAINT bu1 UNIQUE (b1, b2) USING INDEX (create unique index bi on b(b1, b2)), CONSTRAINT bu2 UNIQUE (b2, b1) USING INDEX bi); Example 3:(Tạo bảng c có c1,c2 tạo mục ci theo c1,c2 thêm vào bảng ràng buộc cpk theo primary c1 dùng index ci) CREATE TABLE c(c1 INT, c2 INT); CREATE INDEX ci ON c (c1, c2); ALTER TABLE c ADD CONSTRAINT cpk PRIMARY KEY (c1) USING INDEX ci; Nếu câu lệnh tạo index với ràng buộc dùng index cho ràng buộc khác, hệ thống xếp lại mệnh đề để tạo index trước tái sử dụng • Thu thập thống kê ngẫu nhiên tạo mục Cho hội thu thập thông tin thống kế giá thành tài nguyên nhỏ tạo tái sử dụng index Các thống kê lưu từ điển liệu cho việc sử dụng tới tối ưu việc chọn kế hoạch cho thực lệnh SQL VD: Tính toán index, bảng,thống kê cột xây dựng index emp_ename cột ename bảng emp: CREATE INDEX emp_ename ON emp(ename) COMPUTE STATISTICS; b Thay đổi mục Để thay đổi index Tối thiểu cần điều kiện • • Lược đồ phải chứa mục Có quyền hệ thống ALTER ANY INDEX bảng index Các hoạt động • • Xây dựng lại hay thống mục có Hủy định vị không gian không dùng định vị lại mở rộng • Đặc tả vận hành song song/hoặc không mứa độ song song • Thay đổi tham số lưu trữ hay thuộc tính vật lý • Đặc tả LOGGING hay NOLOGGING • Cho phép hay hủy khóa nén • Đánh dấu mục không dùng • Khởi động hay dừng việc giám sát việc dùng mục Ta thay đổi cấu trúc cột mục(thứ tự??) Nội dung khảo sát: • • Altering Storage Characteristics of an Index Rebuilding an Existing Index • Monitoring Index Usage  Thay đổi đặc tính lưu trữ mục(Lệnh ALTER INDEX) Thay đổi tham số mục bao gồm tạo CSDL để bắt ràng buộc toan vẹn primary key hay unique dùng lệnh ALTER INDEX VD: lệnh thay đổi mục emp_ename: ALTER INDEX emp_ename STORAGE (PCTINCREASE 50); Các tham số INITIAL and MINEXTENTS thay đổi xác định từ đầu Mọi thiết lập tham số ảnh hưởng đến mở rộng (extent) định vị cho mục argument The argument type must be the data type of the queue where your application queues the job-start event If you use the RUN_JOB procedure to manually run a job that has an EVENT_MESSAGE metadata argument, the value passed to that argument is NULL The following example shows how to construct an event-based job that can receive the event message content: create or replace procedure my_stored_proc (event_msg IN event_queue_type) as begin retrieve and process message body other work end; / begin dbms_scheduler.create_program ( program_name => 'my_prog', program_action=> 'my_stored_proc', program_type => 'STORED_PROCEDURE', number_of_arguments => 1, enabled => FALSE) ; dbms_scheduler.define_metadata_argument ( program_name => 'my_prog', argument_position => , metadata_attribute => 'EVENT_MESSAGE') ; dbms_scheduler.enable ('my_prog'); exception when others then raise ; end ; / begin dbms_scheduler.create_job ( job_name => 'my_evt_job' , program_name => 'my_prog', schedule_name => 'my_evt_sch', enabled => true, auto_Drop => false) ; exception when others then raise ; end ; / Using Chains A chain is a named series of programs that are linked together for a combined objective To create and use a chain, you complete these steps in order: Step See Create a chain object Creating Chains Define the steps in the chain Defining Chain Steps Add rules Adding Rules to a Chain Enable the chain Enabling Chains Create a job that points to the chain Creating Jobs for Chains Other topics discussed in this section include: • • Chain Tasks and Their Procedures Dropping Chains • Running Chains • Dropping Rules from a Chain • Disabling Chains • Dropping Chain Steps • Altering Chain Steps • Handling Stalled Chains See Also: • • "Chains" for an overview of chains "Examples of Creating Chains" Chain Tasks and Their Procedures Table 27-9 illustrates common tasks involving chains and the procedures associated with them Table 27-9 Chain Tasks and Their Procedures Task Procedure Privilege Needed Create a chain CREATE_CHAIN CREATE JOB, CREATE EVALUATION CONTEXT and CREATE RULE SET if the owner CREATE ANY JOB, CREATE ANY RULE SET and CREATE ANY EVALUATION CONTEXT otherwise Drop a chain DROP_CHAIN Ownership of the chain or ALTER privileges on the chain or CREATE ANY JOB privileges If not owner, also requires DROP ANY EVALUATION CONTEXT and DROP ANY RULE SET Alter a chain ALTER_CHAIN Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB Alter a chain SET_ATTRIBUTE Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB Alter a running chain ALTER_RUNNING_CHAIN Ownership of the job, or ALTER privileges on the job or CREATE ANY JOB Run a chain RUN_CHAIN CREATE JOB or CREATE ANY JOB In addition, the owner of the new job must have EXECUTE privileges on the chain or EXECUTE ANY PROGRAM Task Procedure Privilege Needed Add rules DEFINE_CHAIN_RULE to a chain Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB privileges CREATE RULE if the owner of the chain, CREATE ANY RULE otherwise Alter rules DEFINE_CHAIN_RULE in a chain Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB privileges If not owner of the chain, requires ALTER privileges on the rule or ALTER ANY RULE DROP_CHAIN_RULE Drop rules from a chain Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB privileges DROP ANY RULE if not the owner of the chain Enable a chain Ownership of the chain, or ALTER privileges on the chain or CREATE ANY ENABLE JOB Disable a DISABLE chain Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB Create steps DEFINE_CHAIN_STEP Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB Drop steps DROP_CHAIN_STEP Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB Alter steps DEFINE_CHAIN_STEP Ownership of the chain, or ALTER privileges on the chain or CREATE ANY JOB Creating Chains You create a chain by using the CREATE_CHAIN procedure After creating the chain object with CREATE_CHAIN, you define chain steps and chain rules separately The rule_set_name and evaluation_interval arguments are normally left NULL evaluation_interval can define the times that chain rules get evaluated, other than when the job starts or a step completes rule_set_name is for advanced users only See Oracle Database PL/SQL Packages and Types Reference for more information on CREATE_CHAIN The following is an example of creating a chain: BEGIN DBMS_SCHEDULER.CREATE_CHAIN ( chain_name => 'my_chain1', rule_set_name => NULL, evaluation_interval => NULL, comments => 'My first chain'); END; / Defining Chain Steps After creating a chain object, you define one or more chain steps Each step can point to one of the following: • • A program Another chain (a nested chain) • An event You define a step that points to a program or nested chain by using the DEFINE_CHAIN_STEP procedure An example is the following, which adds two steps to my_chain1: BEGIN DBMS_SCHEDULER.DEFINE_CHAIN_STEP ( chain_name => 'my_chain1', step_name => 'my_step1', program_name => 'my_program1'); DBMS_SCHEDULER.DEFINE_CHAIN_STEP ( chain_name => 'my_chain1', step_name => 'my_step2', program_name => 'my_chain2'); END; / To define a step that waits for an event to occur, you use the DEFINE_CHAIN_EVENT_STEP procedure Procedure arguments can point to an event schedule or can include an inline queue specification and event condition This example creates a third chain step that waits for the event specified in the named event schedule: BEGIN DBMS_SCHEDULER.DEFINE_CHAIN_EVENT_STEP ( chain_name => 'my_chain1', step_name => 'my_step3', event_schedule_name => 'my_event_schedule'); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the DEFINE_CHAIN_STEP and DEFINE_CHAIN_EVENT_STEP procedures Adding Rules to a Chain Chain rules define when steps run, and define dependencies between steps Each rule has a condition and an action If the condition evaluates to TRUE, the action is performed The condition can contain Scheduler chain condition syntax or any syntax that is valid in a SQL WHERE clause The syntax can include references to attributes of any chain step, including step completion status A typical action is to run a specified step Conditions are usually based on the outcome of one or more previous steps For example, you might want one step to run if the two previous steps succeeded, and another to run if either of the two previous steps failed All rules added to a chain work together to define the overall behavior of the chain When the job starts and at the end of each step, all rules are evaluated to see what action or actions occur next (You can cause rules to be evaluated at regular intervals also See "Creating Chains" for details.) You add a rule to a chain with the DEFINE_CHAIN_RULE procedure You call this procedure once for each rule that you want to add to the chain Starting the Chain At least one rule must have a condition that always evaluates to TRUE so that the chain can start when the job starts The easiest way to accomplish this is to just set the condition to 'TRUE' if you are using Schedule chain condition syntax, or '1=1' if you are using SQL syntax Ending the Chain At least one chain rule must contain an action of 'END' A chain job does not complete until one of the rules containing the END action evaluates to TRUE Several different rules with different END actions are common, some with error codes, and some without If a chain has no more running steps or it is not waiting for an event to occur, and no rules containing the END action evaluate to TRUE (or there are no rules with the END action), the job enters the CHAIN_STALLED state See "Handling Stalled Chains" for more information Example The following example defines a rule that starts the chain at step and a rule that starts step when step completes rule_name and comments are optional and default to NULL BEGIN DBMS_SCHEDULER.DEFINE_CHAIN_RULE ( chain_name => 'my_chain1', condition => 'TRUE', action => 'START step1', rule_name => 'my_rule1', comments => 'start the chain'); DBMS_SCHEDULER.DEFINE_CHAIN_RULE ( chain_name => 'my_chain1', condition => 'step1 completed', action rule_name END; / => => 'START step2', 'my_rule2'); See Also: • Oracle Database PL/SQL Packages and Types Reference for information on the DEFINE_CHAIN_RULE procedure and on Scheduler chain condition syntax • "Examples of Creating Chains" Enabling Chains You enable a chain with the ENABLE procedure A chain must be enabled before it can be run by a job Enabling an already enabled chain does not return an error The following example enables chain my_chain1: BEGIN DBMS_SCHEDULER.ENABLE ('my_chain1'); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the ENABLE procedure Note: Chains are automatically disabled by the Scheduler when: • • The program that one of the chain steps points to is dropped The nested chain that one of the chain steps points to is dropped • The event schedule that one of the chain event steps points to is dropped Creating Jobs for Chains To run a chain, you must either use the RUN_CHAIN procedure or create a job of type 'CHAIN' The job action must refer to the chain name, as shown in the following example: BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'chain_job_1', job_type => 'CHAIN', job_action => 'my_chain1', repeat_interval => 'freq=daily;byhour=13;byminute=0;bysecond=0', enabled => TRUE); END; / For every step of a chain job that is running, the Scheduler creates a step job with the same job name and owner as the chain job Each step job additionally has a job subname to uniquely identify it The job subname is included as a column in the views *_SCHEDULER_RUNNING_JOBS, *_SCHEDULER_JOB_LOG, and *_SCHEDULER_JOB_RUN_DETAILS The job subname is normally the same as the step name except in the following cases: • • For nested chains, the current step name may have already been used as a job subname In this case, the Scheduler appends '_N' to the step name, where N is an integer that results in a unique job subname If there is a failure when creating a step job, the Scheduler logs a FAILED entry in the job log views (*_SCHEDULER_JOB_LOG and *_SCHEDULER_JOB_RUN_DETAILS) with the job subname set to 'step_name_0' See Also: • Oracle Database PL/SQL Packages and Types Reference for more information on the CREATE_JOB procedure • "Running Chains" for another way to run a chain without creating a job ahead of time Dropping Chains You drop a chain, including its steps and rules, by using the DROP_CHAIN procedure An example of dropping a chain is the following, which drops my_chain1: BEGIN DBMS_SCHEDULER.DROP_CHAIN ( chain_name => 'my_chain1', force => TRUE); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the DROP_CHAIN procedure Running Chains You can use the RUN_CHAIN procedure to run a chain immediately, without having to create a job ahead of time for the chain You can also use RUN_CHAIN to run only part of a chain RUN_CHAIN creates a temporary job to run the specified chain If you supply a job name, the job is created with that name, otherwise a default job name is assigned If you supply a list of start steps, only those steps are started when the chain begins running (Steps that would normally have started not run if they are not in the list.) If no list of start steps is given, the chain starts normally—that is, an initial evaluation is done to see which steps to start running An example is the following, which immediately runs the chain my_chain1: BEGIN DBMS_SCHEDULER.RUN_CHAIN ( chain_name => 'my_chain1', job_name => 'quick_chain_job', start_steps => 'my_step1, my_step2'); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the RUN_CHAIN procedure Dropping Rules from a Chain You drop a rule from a chain by using the DROP_CHAIN_RULE procedure An example is the following, which drops my_rule1: BEGIN DBMS_SCHEDULER.DROP_CHAIN_RULE ( chain_name => 'my_chain1', rule_name => 'my_rule1', force => TRUE); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the DROP_CHAIN_RULE procedure Disabling Chains You disable a chain by using the DISABLE procedure An example is the following, which disables my_chain1: BEGIN DBMS_SCHEDULER.DISABLE ('my_chain1'); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the DISABLE procedure Note: Chains are automatically disabled by the Scheduler when: • • The program that one of the chain steps points to is dropped The nested chain that one of the chain steps points to is dropped • The event schedule that one of the chain event steps points to is dropped Dropping Chain Steps You drop a step from a chain by using the DROP_CHAIN_STEP procedure An example is the following, which drops my_step2 from my_chain2: BEGIN DBMS_SCHEDULER.DROP_CHAIN_STEP ( chain_name => 'my_chain2', step_name => 'my_step2', force => TRUE); END; / See Oracle Database PL/SQL Packages and Types Reference for more information regarding the DROP_CHAIN_STEP procedure Altering Chain Steps You alter the SKIP, PAUSE, or RESTART_ON_RECOVERY attributes of a chain step by using the ALTER_CHAIN procedure An example is the following, which causes my_step3 to be skipped: BEGIN DBMS_SCHEDULE.ALTER_CHAIN ( chain_name => 'my_chain1', step_name => 'my_step3', attribute => 'SKIP', value => TRUE); END; / The ALTER_CHAIN procedure affects only future runs of the specified steps You alter the steps in a running chain by using the ALTER_RUNNING_CHAIN procedure An example is the following, which causes step my_step1 to pause after it has completed—that is, its state is changed to PAUSED and its completed attribute remains FALSE: BEGIN DBMS_SCHEDULER.ALTER_RUNNING_CHAIN ( job_name => 'my_job1', step_name => 'my_step1', attribute => 'PAUSE', value => TRUE); END; / The ALTER_RUNNING_CHAIN procedure affects only the running instance of the chain See Oracle Database PL/SQL Packages and Types Reference for more information regarding the ALTER_CHAIN procedure Handling Stalled Chains A chain can become stalled when no steps are running, no steps are scheduled to run, no event steps are waiting for an event, and the evaluation_interval for the chain is NULL The chain can make no further progress unless you manually intervene In this case, the state of the job that is running the chain is set to CHAIN_STALLED (However, the job is still listed in the *_SCHEDULER_RUNNING_JOBS views.) You can troubleshoot a stalled chain with the views ALL_SCHEDULER_RUNNING_CHAINS, which shows the state of all steps in the chain (including any nested chains), and ALL_SCHEDULER_CHAIN_RULES, which contains all the chain rules You can enable the chain to continue by altering the state of one of its steps with the ALTER_RUNNING_CHAIN procedure For example, if step 11 is waiting for step to succeed before it can start, and if it makes sense to so, you can set the state of step to 'SUCCEEDED' Alternatively, if one or more rules are incorrect, you can use the DEFINE_CHAIN_RULE procedure to replace them (using the same rule names), or to create new rules The new and updated rules apply to the running chain and all future chain runs After adding or updating rules, you must run EVALUATE_RUNNING_CHAIN on the stalled chain job to trigger any required actions Allocating Resources Among Jobs It is not practical to manage resource allocation at an individual job level, therefore, the Scheduler uses the concept of job classes to manage resource allocation among jobs In addition to job classes, the Scheduler uses the Resource Manager to manage resource allocation among jobs Allocating Resources Among Jobs Using Resource Manager Resource Manager is the database feature that controls how resources are allocated in the database It not only controls asynchronous sessions like jobs but also synchronous sessions like user sessions It groups all "units of work" in the database into resource consumer groups and uses a resource plan to specify how the resources will be allocated among the various groups See Chapter 24, "Using the Database Resource Manager" for more information about what resources are controlled by resource manager For jobs, resource allocation is specified by associating a job class with a consumer group, or by associating a job class with a database service name and mapping that database service to a consumer group The consumer group that a job class maps to can be specified when creating a job class If no resource consumer group or database service name is specified when a job class is created, the job class will map to the default consumer group The Scheduler tries to limit the number of jobs that are running simultaneously so that at least some jobs can complete, rather than running a lot of jobs concurrently but without enough resources for any of them to complete The Scheduler and Resource Manager are tightly integrated The job coordinator obtains database resource availability from Resource Manager Based on that information, the coordinator determines how many jobs to start It will only start jobs from those job classes that will have enough resources to run The coordinator will keep starting jobs in a particular job class that maps to a consumer group until Resource Manager determines that the maximum resource allocated for that consumer group has been reached This means that it is possible that there will be jobs in the job table that are ready to run but will not be picked up by the job coordinator because there are no resources to run them Therefore, there is no guarantee that a job will run at the exact time that it was scheduled The coordinator picks up jobs from the job table on the basis of which consumer groups still have resources available Even when jobs are running, Resource Manager will continue to manage the amount of CPU cycles that are assigned to each running job based on the specified resource plan Keep in mind that Resource Manager can only manage database processes The active management of CPU cycles does not apply to jobs of type executable In a database, only one resource plan can be in effect at one time It is possible to manually switch the resource plan that is active on a system using the DBMS_RESOURCE_MANAGER.SWITCH_PLAN procedure In special scenarios, you might want to run a specific resource plan and disable resource plan switches caused by windows opening To this, you can use the DBMS_RESOURCE_MANAGER.SWITCH_PLAN procedure with allow_scheduler_plan_switches set to FALSE In a Real Application Clusters environment, the same resource plan will be in effect on every database instance Example of Resource Allocation for Jobs The following example can help to understand how resources are allocated for jobs Assume that the active resource plan is called "Night Plan" and that there are three job classes: JC1, which maps to consumer group DW; JC2, which maps to consumer group OLTP; and JC3, which maps to the default consumer group Figure 27-3 offers a simple graphical illustration of this scenario Figure 27-3 Sample Resource Plan Description of "Figure 27-3 Sample Resource Plan" This resource plan clearly gives priority to jobs that are part of job class JC1 Consumer group DW gets 60% of the resources, thus jobs that belong to job class JC1 will get 60% of the resources Consumer group OLTP has 30% of the resources, which implies that jobs in job class JC2 will get 30% of the resources The consumer group Other specifies that all other consumer groups will be getting 10% of the resources This means that all jobs that belong in job class JC3 will share 10% of the resources and can get a maximum of 10% of the resources Affinity: giống nhau, đồng cảm, lựa Awacke: nhận thức , đánh thức RAC: Real Application Cluster SGA:shared Global Area? Coalesing:gắn, kết hợp lại Lesser (ttu so sánh): hơn, nhỏ Brough(bring) đưa lại Substain(v): chống đỡ, kéo dài,chấp nhận Disruption:gẫy vỡ, chia rẽ, đánh thủng Mutally: qua lai Exculsive: doc quyen, danh rieng [...]... quan về bộ lập lịch Cho phép người quản trị và người phát triển giám sát các tác vụ khi nào và ở đâu trong môi trường CSDL Các tác vụ có thể tiêu tốn thời gian và phức tạp nên bộ lập lịch để cải thi n việc quản trị và lập kế hoạch cho các tác vụ này Nó giúp cho không cần thủ công, các routin tin cậy, giá thành, giảm thi u lỗi và rút ngắn thời gian Ví dụ: • Người quản trị cần lập lịch và giám sát việc... trữ hay chuyển các phân đoạn giữa các khối Nó hiệu quả hơn khi bỏ chỉ mục và dùng CREAT INDEX VD: Xây dựng lại index đang có emp_name: ALTER INDEX emp_name REBUILD; Mệnh đề REBUILD phải đi ngay sau tên của chỉ mục Nó không thể conjuntion với mệnh đề DEALLOCATE UNUSED Ta có tùy chọn xây dựng lại trực tuyến(cho phép cập nhật các bảng cơ sở đồng thời khi xây dựng lại) – dùng mệnh đề ONLINE: ALTER INDEX... gồm mệnh đề con USING UNDEX của mệnh đề ENABLE, VD: Ví dụ hiệu chỉnh tùy chọn lưu trữ của bảng emp theo ràng buộc primary key: ALTER TABLE emp ENABLE PRIMARY KEY USING INDEX;  Thay đổi có Xây dựng lại một chỉ mục đang có (Mệnh đề REBUILD) Trước khi xây dựng lại một chỉ mục đã có, cần cân nhắc giá thnahf (rebuid hay coalesce) theo bảng 16-1 Khi xây dựng lại một chỉ mục, ta dùng index cũ như dữ liệu nguồn... doanh nghiệp yêu cầu Quản trị và giám sát tác vụ • Vận hành và giám sát tác vụ trong môi trường cluster • • Schedule job execution based on time or events Schedule job processing in a way that models your business requirements The Scheduler enables limited computing resources to be allocated appropriately among competing jobs, thus aligning job processing with your business needs This is accomplished... from a bank account than is available In this case, you could run jobs that check for suspicious activity in this account • Manage and monitor jobs There are multiple states that a job undergoes from its creation to its completion Scheduler activity is logged and information such as the status of the job and the last run time of the job can be easily tracked This information is stored in views and can... thực hiện lập lịch tự động, đơn giản quản trị tác vụ, Oracle cung cấp các chức năng và thủ tục trong gói DBMA_SCHEDULER Chúng là bộ lập lịch, có khả năng lập trình từ PL/SQL Có khả năng lập lịch các tác vụ thông qua Bộ lập lịch Oracle • • Overview of the Scheduler Basic Scheduler Concepts • Advanced Scheduler Concepts • Scheduler Architecture Các khái niệm bộ lập lịch cơ bản Các phần tử của bọ lập lịch... Manager" for more information on mapping services to consumer groups • Group jobs for prioritization Within the same job class, you can assign priority values of 1 -5 to individual jobs so that if two jobs in the class are scheduled to start at the same time, the one with the higher priority takes precedence This ensures that you do not have a less important job preventing the timely completion of a more... Manager" for more information on mapping services to consumer groups • Group jobs for prioritization Within the same job class, you can assign priority values of 1 -5 to individual jobs so that if two jobs in the class are scheduled to start at the same time, the one with the higher priority takes precedence This ensures that you do not have a less important job preventing the timely completion of a more... Programs, Jobs, và Schedules quan hệ với nhau thế nào Để định nghĩa vận hành cái gì và khi nào ta gán quan hệ giữa các programs, jobs, và schedules Xem hình Các khái niệm lập lịch nâng cao Cho phép người quản trị CSDL giám sát nhiều khía cạnh tiên tiến của lập lịch Người phát triển thì không cần • • Các lớp công việc-Job Classes Các cửa sổ-Windows • Các nhóm cửa sổ- Window Groups Job Classes Job classes... được so với các phương pháp khác Nếu báo lỗi ORA-1 450 (maximum key length exceeded) khi xây dựng lại online thì nên dùng rebuilding offline, coalescing, or dropping and recreating the index Nếu không có không gian yêu cầu để xây dựng lại thì thay bằng coalesce Coalescing an index is an online operation  Thay đổi có Giám sát việc sử dụng chỉ mục (Mệnh đề MONITORING USAGE) CSDL Oracle cung cấp phương ... trúc Bitmap: Bitmap: có bitmap cho cac giá tri liệu, đối sánh tìm kiếm Có tác dụng cột có giá trị nhỏ(VD: Nam Nũ) o Giá trị khóa(cặp độ dài-giá trị= giá trị khóa)—Start ROWID—End ROWID—bitmap segment... quan lập lịch Cho phép người quản trị người phát triển giám sát tác vụ đâu môi trường CSDL Các tác vụ tiêu tốn thời gian phức tạp nên lập lịch để cải thi n việc quản trị lập kế hoạch cho tác vụ... o Các giá trị tương đối cột o Có phạm vi giá trị rông (tốt dùng mục thông thường) o Có phạm vi gtri nhỏ( tốt cho mục bitmap) o Các cột chứa giá trị null, truy vấn chọn hàng có giá trị Ví dụ

Ngày đăng: 17/01/2016, 00:09

Từ khóa liên quan

Mục lục

  • 2.1.1 Tổng quan ( Chỉ mục là gì?Tại sao lập chỉ mục)

  • Là một cấu trúc tùy chọn cho các bảng hay các bó dữ liệu. Nó tăng tốc quá trình làm việc với bảng chỉ với các truy vấn đơn giản. Ta có được hiển thị và thao tác trên bảng nhanh hơn

  • Có thể lập, hủy chỉ mục mà không ảnh hưởng đến bảng

  • Các loại chỉ mục

  • ==

  • Chỉ mục hoạt động thế nào

  • Tạo chỉ mục sau khi có dữ liệu bảng

  • Chỉ mục yêu cầu không gian nhớ không lớn.

  • Lập chỉ mục đúng các bảng và các cột chỉ nên lập chỉ mục khi

  • Xử lý ít dữ liêu(<15% số hàng)

  • Cần hoàn thiện khả năng liên kết nhiều bảng, các cột chỉ mục dùng cho join

  • Không nên làm với CSDL nhỏ

  • Có thể dùng các cột ứng viên cho chỉ mục

  • 2.1.2 Trường hợp nghiên cứu

  • 2.1.2.1 Chỉ mục trong Oracle(Các khái niệm)

  • Trong Oracle

  • Tạo chỉ mục sau khi có dữ liệu bảng

  • Có thể có được nhờ SQL*Loader hay import. Điều này nhanh hơn khi tạo dữ liệu rồi mới tạo chỉ mục

  • Chỉ mục yêu cầu không gian nhớ không lớn.

  • Có thể dùng mặc định hay qua tham số Sort_AREA_SIZE

Tài liệu cùng người dùng

Tài liệu liên quan