Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-7352

Improve OrderPreservingTracker to support extracting partial ordering columns for TupleProjectionPlan

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.2.0
    • 5.2.1, 5.3.0
    • core
    • None

    Description

      This is an improvement for PHOENIX-5148:
      Given a table:

        create table test ( 
             pk1 varchar not null , 
             pk2 varchar not null, 
             pk3 varchar not null,
             v1 varchar, 
             v2 varchar, 
             CONSTRAINT TEST_PK PRIMARY KEY ( 
                   pk1,
                   pk2,
                   pk3 ))
      

      PHOENIX-5148 optimized following sql to compile outer OrderBy "order by v2, pk3" because it matches the inner query OrderBy "order by t.v2, t.pk3, t.v1":

      select v1 from (select v1, v2, pk3 from test t where pk1 = '6' order by t.v2, t.pk3, t.v1 limit 10) a order by v2, pk3
      

      But if we make a small change to the sql above, just remove the t.v1 in inner query OrderBy "order by t.v2, t.pk3, t.v1":

      select v1 from (select v1, v2, pk3 from test t where pk1 = '6' order by t.v2, t.pk3 limit 10) a order by v2, pk3
      

      Obviously, the outer OrderBy "order by v2,pk3" should still be compiled out because it matches the inner query OrderBy "order by t.v2, t.pk3" , but unfortunately it could not be compiled out now.

      That is because for the inner query of the second sql, we infer the output OrderBy from "select v1, v2, pk3" based on "order by t.v2, t.pk3". This work is done by OrderPreservingTracker in TupleProjectionPlan . But for OrderPreservingTracker, it could not support extracting partial ordering columns, when it finds that v1 in "select v1, v2, pk3" does not appear in "order by t.v2, t.pk3", OrderPreservingTracker.isOrderPreserving returns false, and
      OrderPreservingTracker.getOrderPreservingTrackInfos returns an empty list in TupleProjectionPlan.

      We should modify OrderPreservingTracker to make OrderPreservingTracker.getOrderPreservingTrackInfos could also extract partial continuous ordering columns which start from the first column even if OrderPreservingTracker.isOrderPreserving is false. That is to say, even if v1 in "select v1, v2, pk3" does not appear in "order by t.v2, t.pk3", it will return the partial ordered "v2, pk3".

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            comnetwork chenglei
            comnetwork chenglei
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment