Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add opt rule to push down STARTS WITH expr #4433

Merged
merged 4 commits into from
Jul 19, 2022

Conversation

Aiee
Copy link
Contributor

@Aiee Aiee commented Jul 15, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

Rewrite STARTS WITH to AND expr and trigger TagIndexRangeScan if an index is avaliable.

(root@nebula) [nba]> EXPLAIN  lookup on player where player.name starts with "Tim" YIELD player.name
Execution succeeded (time spent 1040/1368 us)

Execution Plan (optimize time 514 us)

-----+-------------------+--------------+----------------+--------------------------------
| id | name              | dependencies | profiling data | operator info                 |
-----+-------------------+--------------+----------------+--------------------------------
|  3 | Project           | 4            |                | outputVar: {                  |
|    |                   |              |                |   "colNames": [               |
|    |                   |              |                |     "player.name"             |
|    |                   |              |                |   ],                          |
|    |                   |              |                |   "type": "DATASET",          |
|    |                   |              |                |   "name": "__Project_3"       |
|    |                   |              |                | }                             |
|    |                   |              |                | inputVar: __Filter_2          |
|    |                   |              |                | columns: [                    |
|    |                   |              |                |   "player.name"               |
|    |                   |              |                | ]                             |
-----+-------------------+--------------+----------------+--------------------------------
|  4 | TagIndexRangeScan | 0            |                | outputVar: {                  |
|    |                   |              |                |   "colNames": [               |
|    |                   |              |                |     "_vid",                   |
|    |                   |              |                |     "player.name"             |
|    |                   |              |                |   ],                          |
|    |                   |              |                |   "name": "__Filter_2",       |
|    |                   |              |                |   "type": "DATASET"           |
|    |                   |              |                | }                             |
|    |                   |              |                | inputVar:                     |
|    |                   |              |                | space: 1                      |
|    |                   |              |                | dedup: false                  |
|    |                   |              |                | limit: 9223372036854775807    |
|    |                   |              |                | filter:                       |
|    |                   |              |                | orderBy: []                   |
|    |                   |              |                | schemaId: 2                   |
|    |                   |              |                | isEdge: false                 |
|    |                   |              |                | returnCols: [                 |
|    |                   |              |                |   "_vid",                     |
|    |                   |              |                |   "name"                      |
|    |                   |              |                | ]                             |
|    |                   |              |                | indexCtx: [                   |
|    |                   |              |                |   {                           |
|    |                   |              |                |     "columnHints": [          |
|    |                   |              |                |       {                       |
|    |                   |              |                |         "beginValue": "Tim",  |
|    |                   |              |                |         "includeEnd": false,  |
|    |                   |              |                |         "includeBegin": true, |
|    |                   |              |                |         "endValue": "Tin",    |
|    |                   |              |                |         "column": "name",     |
|    |                   |              |                |         "scanType": "RANGE"   |
|    |                   |              |                |       }                       |
|    |                   |              |                |     ],                        |
|    |                   |              |                |     "index_id": 8,            |
|    |                   |              |                |     "filter": ""              |
|    |                   |              |                |   }                           |
|    |                   |              |                | ]                             |
-----+-------------------+--------------+----------------+--------------------------------
|  0 | Start             |              |                | outputVar: {                  |
|    |                   |              |                |   "colNames": [],             |
|    |                   |              |                |   "name": "__Start_0",        |
|    |                   |              |                |   "type": "DATASET"           |
|    |                   |              |                | }                             |
-----+-------------------+--------------+----------------+--------------------------------

Fri, 15 Jul 2022 21:55:13 CST

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

@Aiee Aiee added type/enhancement Type: make the code neat or more efficient ready-for-testing PR: ready for the CI test ready for review labels Jul 15, 2022
@Aiee Aiee requested review from cangfengzhs and jievince July 15, 2022 14:30
jievince
jievince previously approved these changes Jul 15, 2022
Copy link
Contributor

@jievince jievince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

@Sophie-Xie Sophie-Xie added this to the v3.3.0 milestone Jul 18, 2022
cangfengzhs
cangfengzhs previously approved these changes Jul 18, 2022
@Aiee Aiee dismissed stale reviews from cangfengzhs and jievince via 0371588 July 18, 2022 07:57
@Aiee Aiee requested a review from jievince July 18, 2022 08:06
@codesigner codesigner merged commit 96b68b7 into vesoft-inc:master Jul 19, 2022
@Aiee Aiee deleted the starts-with branch July 19, 2022 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready-for-testing PR: ready for the CI test type/enhancement Type: make the code neat or more efficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants