This is an automated email from the ASF dual-hosted git repository.

wyk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new d410189342 [ASTERIXDB-3359][COMP] Project only the necessary columns 
on delete
d410189342 is described below

commit d410189342abf7a66382b7ebfa50edf8509fbb32
Author: Wail Alkowaileet <[email protected]>
AuthorDate: Wed Feb 21 12:23:11 2024 -0800

    [ASTERIXDB-3359][COMP] Project only the necessary columns on delete
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    When a delete operation is initiated, all columns will be projected.
    This is inefficient as only a few columns are needed. Namely, the
    columns of the delete predicate and the indexed columns (if any).
    
    Change-Id: I51a26f40b1ba0597a66f08a78097cd20a42c4c76
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18172
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Wail Alkowaileet <[email protected]>
    Reviewed-by: Murtadha Hubail <[email protected]>
---
 .../processor/ColumnValueAccessPushdownProcessor.java  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnValueAccessPushdownProcessor.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnValueAccessPushdownProcessor.java
index 7db3dd24f3..30844a73f1 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnValueAccessPushdownProcessor.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnValueAccessPushdownProcessor.java
@@ -32,8 +32,10 @@ import 
org.apache.asterix.optimizer.rules.pushdown.visitor.ExpressionValueAccess
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
 import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
 import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
 import 
org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator;
 
 /**
  * Computes the expected schema for columnar datasets (whether internal or 
external). The expected schema is then
@@ -84,6 +86,13 @@ public class ColumnValueAccessPushdownProcessor extends 
AbstractPushdownProcesso
         for (UseDescriptor useDescriptor : useDescriptors) {
             LogicalVariable producedVariable = 
useDescriptor.getProducedVariable();
             ILogicalOperator op = useDescriptor.getOperator();
+            if (isDelete(op)) {
+                /*
+                 * Delete operation uses the record variable as an expression. 
Hence, all fields will be projected.
+                 * This is inefficient as only the columns of the delete 
predicate AND the indexed columns are needed.
+                 */
+                continue;
+            }
             IVariableTypeEnvironment typeEnv = PushdownUtil.getTypeEnv(op, 
context);
             expressionVisitor.transform(useDescriptor.getExpression(), 
producedVariable, typeEnv);
         }
@@ -101,4 +110,13 @@ public class ColumnValueAccessPushdownProcessor extends 
AbstractPushdownProcesso
             }
         }
     }
+
+    private boolean isDelete(ILogicalOperator op) {
+        if (op.getOperatorTag() != LogicalOperatorTag.INSERT_DELETE_UPSERT) {
+            return false;
+        }
+
+        InsertDeleteUpsertOperator deleteOp = (InsertDeleteUpsertOperator) op;
+        return deleteOp.getOperation() == 
InsertDeleteUpsertOperator.Kind.DELETE;
+    }
 }

Reply via email to