Improve PHP performance by caching database results (3 ). Adding a table to the previous section of existing registration describes how to use the change notification service to notify the database when the registration object (ORDERS table in the preceding example) is changed. But from
Add a table to an existing registration
The previous section describes how to use the change notification service to enable
DatabaseRegister
Object(ORDERS in the preceding example
Table. However, from a performance perspective, client applications may prefer to cache ORDER_ITEMS tables rather than ORDERS
The query result set of the table itself, because it has to retrieve only one row from the ORDERS table each time it accesses the order, but at the same time it must
Multiple rows are retrieved from the table. In practice, an order may contain dozens or even hundreds of orders.
Since you have registered a query for the ORDERS table, you do not have to create another registration
The ORDER_ITEMS table is queried. Instead, you can use existing registration. To do this, you must first retrieve the existing registered ID. You can execute the following query to complete this
Work:
SELECT regid, table_name FROM user_change_notification_regs;
The result may be as follows:
REGID TABLE_NAME
----- --------------
241 OE.ORDERS
After obtaining the registration ID, you can use dbms_change_icationication.enable_reg
The function adds a new object to the registration, as shown below:
DECLARE
ord_id NUMBER;
BEGIN
DBMS_CHANGE_NOTIFICATION.ENABLE_REG(241);
SELECT order_id INTO ord_id FROM order_items WHERE ROWNUM < 2;
DBMS_CHANGE_NOTIFICATION.REG_END;
END;
/
Finished! From now on, the database will generate a notification to respond to any changes made to ORDERS and ORDER_ITEMS, and call
Orders_nf_callback process to process notifications. Therefore, the next step is to edit orders_nf_callback so that it can process
Notification generated when the table performs the DML operation. However, before re-creating the orders_nf_callback process, you must create the following table types that will be referenced during the update process:
CREATE TYPE rdesc_tab AS TABLE OF SYS.CHNF$_RDESC;
Then, return to the list
2. after the following code lines:
IF (tblname = 'OE.ORDERS') THEN
FOR j IN 1..numrows LOOP
row_id := ntfnds.table_desc_array(i).row_desc_array(j).row_id;
SELECT order_id INTO ord_id FROM orders WHERE rowid = row_id;
sendNotification(url, tblname, ord_id);
END LOOP;
END IF;
Insert the following code:
IF (tblname = 'Oe. ORDER_ITEMS ') THEN
The previous section describes how to use the change notification service to notify the database when the registered object (ORDERS table in the preceding example) is changed. But from...