Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 85418 invoked from network); 12 Apr 2006 23:24:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Apr 2006 23:24:24 -0000 Received: (qmail 60308 invoked by uid 500); 12 Apr 2006 23:24:23 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 60081 invoked by uid 500); 12 Apr 2006 23:24:23 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 60069 invoked by uid 99); 12 Apr 2006 23:24:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Apr 2006 16:24:22 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Apr 2006 16:24:20 -0700 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id A0B63D4A02 for ; Thu, 13 Apr 2006 00:23:59 +0100 (BST) Message-ID: <1275603635.1144884239654.JavaMail.jira@ajax> Date: Thu, 13 Apr 2006 00:23:59 +0100 (BST) From: "Manish Khettry (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-442) Update triggers on tables with blob columns stream blobs into memory even when the blobs are not referenced/accessed. In-Reply-To: <1056780379.1120671195372.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-442?page=comments#action_12374273 ] Manish Khettry commented on DERBY-442: -------------------------------------- If we have triggers on a table, we end up reading all the columns from the base table. This bit of code in UpdateNode#getUpdateReadMap, says: /* ** If we have any triggers, then get all the columns ** because we don't know what the user will ultimately ** reference. */ baseTable.getAllRelevantTriggers( StatementType.UPDATE, changedColumnIds, relevantTriggers ); if ( relevantTriggers.size() > 0 ) { needsDeferredProcessing[0] = true; } if (relevantTriggers.size() > 0) { for (int i = 1; i <= columnCount; i++) { columnMap.set(i); } } If we want to be smart and not read the columns which are not needed by the trigger, the trigger descriptor and the system table will have to remember which columns are referenced by the trigger. Confusingly, the referencedcolumns column of SYSTRIGGERS actually contains the triggering columns! > Update triggers on tables with blob columns stream blobs into memory even when the blobs are not referenced/accessed. > --------------------------------------------------------------------------------------------------------------------- > > Key: DERBY-442 > URL: http://issues.apache.org/jira/browse/DERBY-442 > Project: Derby > Type: Sub-task > Components: SQL > Versions: 10.2.0.0 > Reporter: A B > Priority: Minor > Fix For: 10.2.0.0 > Attachments: d442.java > > Suppose I have 1) a table "t1" with blob data in it, and 2) an UPDATE trigger "tr1" defined on that table, where the triggered-SQL-action for "tr1" does NOT reference any of the blob columns in the table. [ Note that this is different from DERBY-438 because DERBY-438 deals with triggers that _do_ reference the blob column(s), whereas this issue deals with triggers that do _not_ reference the blob columns--but I think they're related, so I'm creating this as subtask to 438 ]. In such a case, if the trigger is fired, the blob data will be streamed into memory and thus consume JVM heap, even though it (the blob data) is never actually referenced/accessed by the trigger statement. > For example, suppose we have the following DDL: > create table t1 (id int, status smallint, bl blob(2G)); > create table t2 (id int, updated int default 0); > create trigger tr1 after update of status on t1 referencing new as n_row for each row mode db2sql update t2 set updated = updated + 1 where t2.id = n_row.id; > Then if t1 and t2 both have data and we make a call to: > update t1 set status = 3; > the trigger tr1 will fire, which will cause the blob column in t1 to be streamed into memory for each row affected by the trigger. The result is that, if the blob data is large, we end up using a lot of JVM memory when we really shouldn't have to (at least, in _theory_ we shouldn't have to...). > Ideally, Derby could figure out whether or not the blob column is referenced, and avoid streaming the lob into memory whenever possible (hence this is probably more of an "enhancement" request than a bug)... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira