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

[CBRD-24795] When using a function under <= and >= conditions, the plan generator does not perform a range scan (#4365, #4830) #5938

Draft
wants to merge 2 commits into
base: release/11.3
Choose a base branch
from

Conversation

youngjinj
Copy link
Contributor

…an generator does not perform a range scan (CUBRID#4365)

http://jira.cubrid.org/browse/CBRD-24795

Make the function expression used in the function index the target in the process of rewriting the query below.
1. qo_converse_sarg_terms
   - convert terms of the form 'const op attr' to 'attr op const'
   ```
   (-) attribute1 operation (-) attribute2 → attribute1 converse_operation attribute2
   [ x ] (-) attribute1 operation attribute2 → attribute1 converse_operation (-) attribute2
   (-) attribute1 operation constant → attribute1 converse_operation (-) constant
   constant operation (-) attribute1 → (-) constant converse_operation attribute1
   
   /* swap */
   attribute2 CUBRID#1 operation attribute1 CUBRID#3 → attribute1 CUBRID#3 converse_operation attribute2 CUBRID#1
   constant operation attribute1 → attribute1 converse_operation constant
   ```
2. qo_reduce_comp_pair_terms (qo_search_comp_pair_term)
   - reduce a pair of comparison terms into one BETWEEN term
   ```
   attribute operation const1 AND attribute operation const2
    → attribute BETWEEN const1 PT_BETWEEN_operation> const2
   ```
3. qo_convert_to_range (qo_convert_to_range_helper, qo_merge_range_helper)
   - convert comparison terms to RANGE
   ```
   attribute1 operation constant1 OR attribute1 operation constant2
   → attribute1 RANGE (constant1 operation gt_inf max OR min inf_lt constant2)
   
   attribute1 BETWEEN constant1 gt_lt constant2
   → attribute1 RANGE (constant1 gt_lt constant2)
   
   attribute1 IN (constant1, constant2, constant3);
   → attribute1 RANGE (constant1 = OR constant2 = OR constant3 =)
   
   /* merge */
   (attribute1 operation constant1 OR attribute1 operation constant3) AND (attribute1 operation constant2 OR attribute1 operation constant3)
   → (attribute1 operation constant1) AND (attribute1 operation constant2 OR attribute1 operation constant3)
   ```
4. qo_apply_range_intersection (qo_apply_range_intersection_helper)
   - narrow search range by applying range intersection
   ```
   /* merge */
   attribute1 RANGE (constant1 operation constant2) AND attribute1 RANGE (constant3 = OR constant4 = OR constant5 =)
   → attribute1 RANGE (constant3 = OR constant4 = OR constant5 =)
   ```
5. qo_do_auto_parameterize
   - auto-parameterize convert value in expression to host variable (input marker)
…heck_path_eq function (CUBRID#4830)

http://jira.cubrid.org/browse/CBRD-24795
http://jira.cubrid.org/browse/CBRD-25116

### Fixed incorrect checking of the return value of the pt_check_path_eq function
In CBRD-24795, checking by calling the pt_name_equal function was changed to checking by calling the pt_check_path_eq  function. If the two are equal, the pt_name_equal function returns true (!= 0), but the pt_check_path_eq function returns 0. After changing the calling function, incorrect checking of the return value was occurring. And it was fixed.
```
drop table if exists t1;
create table t1 (a int, b int, c int, d int, e int);
create index idx_t1_abs_b_a on t1 (abs (b), a);

set optimization level 513;

select /*+ recompile ordered */ ta.*
from t1 ta, t1 tb
where (ta.b = abs (tb.b) or ta.c = abs (tb.b))
and ta.a = tb.a;
```

**AS-IS**
- The following predicate must be indexable.
```
term[0]: (ta.b range ( abs(tb.b) = ) or ta.c range ( abs(tb.b) = )) (sel 0.001999) (rank 2) (join term) (inner-join) (loc 0)
```

**TO-BE**
```
term[0]:  abs(tb.b) range (ta.b =  or ta.c = ) (sel 0.001999) (rank 3) (join term) (inner-join) (indexable  abs([dba.t1].[b])[1]) (loc 0)
```
@youngjinj youngjinj added this to the 11.3 Patch 3 milestone Feb 24, 2025
@youngjinj youngjinj self-assigned this Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant