[
https://issues.apache.org/jira/browse/ASTERIXDB-3543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17922148#comment-17922148
]
Ali Alsuliman commented on ASTERIXDB-3543:
------------------------------------------
Hi [~wyk],
Thanks for commenting!
The issue here is actually that single reference inlining was fired. An
expression (e.g. field access) involving the record got inlined to the top of
the plan. So, the record variable cannot be projected because it's used at the
top of the plan. A simple example is:
{code:sql}
SELECT a.x, h.s AS s
FROM coll a
UNNEST a.events h
WHERE h.t >= "2020-01-01T09:04:57.750006+00:00";
{code}
The plan roughly would look like:
{code:sql}
distribute result [$$72]
-- DISTRIBUTE_RESULT |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
project ([$$72])
-- STREAM_PROJECT |PARTITIONED|
assign [$$72] <- [{"x": $$a.getField("x"), "s": $$h.getField("s")]
-- ASSIGN |PARTITIONED|
select (ge($$h.getField("t"), "2020-01-01T09:04:57.750006+00:00"))
-- STREAM_SELECT |PARTITIONED|
project ([$$a, $$h])
-- STREAM_PROJECT |PARTITIONED|
unnest $$h <- scan-collection($$84)
-- UNNEST |PARTITIONED|
assign [$$84] <- [$$a.getField("events")]
-- ASSIGN |PARTITIONED|
project ([$$a])
-- STREAM_PROJECT |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
data-scan []<-[$$16, $$a] <- Default.coll
-- DATASOURCE_SCAN |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
empty-tuple-source
-- EMPTY_TUPLE_SOURCE |PARTITIONED|
{code}
Do you recall we had a discussion about this? We were discussing when this rule
`InlineSingleReferenceVariablesRule` is helpful. You mentioned few cases that I
don't remember now.
> Investigate single reference inlining rule
> ------------------------------------------
>
> Key: ASTERIXDB-3543
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-3543
> Project: Apache AsterixDB
> Issue Type: Task
> Components: COMP - Compiler
> Reporter: Vijay Sarathy
> Assignee: Vijay Sarathy
> Priority: Major
> Labels: triaged
>
> Query takes too long when field accesses get inlined, resulting in the
> document not being projected early at the beginning of the plan. Investigate
> this issue and suggest improvements as part of this task.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)