[ 
https://issues.apache.org/jira/browse/DERBY-4538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mamta A. Satoor updated DERBY-4538:
-----------------------------------

    Attachment: DERBY4538_NoReferencingClause_stat_v1.txt
                DERBY4538_NoReferencingClause_diff_v1.txt

I am attaching a patch (not ready for commit yet), 
DERBY4538_NoReferencingClause_diff_v1.txt. This patch takes care of UPDATE 
triggers with no REFERENCING clause defined on them. During Update, Derby tries 
to determine which columns need to be read from the triggering table. As soon 
as we find out that the update table has triggers defined on it, we decide to 
read all the columns. We can improve on this algorithm My patch is attempting 
to be more intelligant about what columns should be read. The new logic is as 
follows.
        /*
        ** If we have any triggers, then do one of the following
        ** 1)If all of the triggers have MISSING referencing clause, then that
        ** means that the trigger actions do not have access to before and 
        ** after values. In that case, there is no need to blanketly decide to
        ** include all the columns in the read map just because there are
        ** triggers defined on the table.
        ** 2)Since one/more triggers have REFERENCING clause on them, get all 
        ** the columns because we don't know what the user will ultimately 
reference.
        */

Would love to hear if anyone has any feedback on this approach. Similar changes 
need to go in for INSERT and UPDATE statements. I will post a patch which will 
include those changes once i have it ready.

> If the CREATE TRIGGER does not have the REFERENCING clause, then there is no 
> need to keep before and after values for the triggering table
> ------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4538
>                 URL: https://issues.apache.org/jira/browse/DERBY-4538
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.6.0.0
>            Reporter: Mamta A. Satoor
>            Assignee: Mamta A. Satoor
>            Priority: Minor
>         Attachments: DERBY4538_NoReferencingClause_diff_v1.txt, 
> DERBY4538_NoReferencingClause_stat_v1.txt
>
>
> In order for the trigger action to have access to before and after values of 
> the triggering table, the CREATE TRIGGER should use the REFERENCING clause. 
> Without the REFERENCING clause, old and new values of triggering table can't 
> be accessed by the trigger action. Based on this, we can improve Derby memory 
> utilization by not keeping old and new values if REFERENCING clause is 
> missing. It will be good to see if the code already does this optimization 
> and if not, then introducing this optimization will definitely be very useful 
> when the triggering table could have LOB columns.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to