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

commonTerms optimizer no longer works #7490

Closed
swingbit opened this issue Mar 26, 2024 · 2 comments
Closed

commonTerms optimizer no longer works #7490

swingbit opened this issue Mar 26, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@swingbit
Copy link

swingbit commented Mar 26, 2024

Describe the bug
Trivially reusable intermediates are not reused.

To Reproduce

start transaction;

-- a small table
create table t(value int);
insert into t values (0),(2),(1);

explain
SELECT * from t where value=0
UNION ALL
SELECT * from t where value=0;

The explain shows two distinct binds for the same column. Which means two distinct selects that are in fact identical. In real queries this can explode.

| function user.main():void;                                                                                                                               |
|     X_1:void := querylog.define("explain\nselect * from t where value=0\nunion all\nselect * from t where value=0;":str, "sequential_pipe":str, 22:int); |
|     X_4:int := sql.mvc();                                                                                                                                |
|     C_5:bat[:oid] := sql.tid(X_4:int, "sys":str, "t":str);                                                                                               |
|     X_8:bat[:int] := sql.bind(X_4:int, "sys":str, "t":str, "value":str, 0:int);                                                                          |
|     C_13:bat[:oid] := algebra.thetaselect(X_8:bat[:int], C_5:bat[:oid], 0:int, "==":str);                                                                |
|     X_15:bat[:int] := algebra.projection(C_13:bat[:oid], X_8:bat[:int]);                                                                                 |
|     X_17:bat[:int] := sql.bind(X_4:int, "sys":str, "t":str, "value":str, 0:int);                                                                         |
|     C_19:bat[:oid] := algebra.thetaselect(X_17:bat[:int], C_5:bat[:oid], 0:int, "==":str);                                                               |
|     X_20:bat[:int] := algebra.projection(C_19:bat[:oid], X_17:bat[:int]);                                                                                |
|     X_21:bat[:int] := bat.new(nil:int);                                                                                                                  |
|     X_23:bat[:int] := bat.append(X_21:bat[:int], X_15:bat[:int], true:bit);                                                                              |
|     X_25:bat[:int] := bat.append(X_23:bat[:int], X_20:bat[:int], true:bit);                                                                              |
|     X_27:bat[:str] := bat.pack(".%5":str);                                                                                                               |
|     X_28:bat[:str] := bat.pack("value":str);                                                                                                             |
|     X_29:bat[:str] := bat.pack("int":str);                                                                                                               |
|     X_30:bat[:int] := bat.pack(32:int);                                                                                                                  |
|     X_31:bat[:int] := bat.pack(0:int);                                                                                                                   |
|     X_26:int := sql.resultSet(X_27:bat[:str], X_28:bat[:str], X_29:bat[:str], X_30:bat[:int], X_31:bat[:int], X_25:bat[:int]);                           |
| end user.main;                                                                                                                                           |

Expected behavior
Only one bind to column value is made and the associated variable used twice, leading to only one select.

Software versions

  • MonetDB version number 11.49.6
  • OS and version: Fedora 39
  • self-installed and compiled
@njnes
Copy link
Contributor

njnes commented Apr 7, 2024

fixed in dec2023

@njnes njnes closed this as completed Apr 7, 2024
@njnes
Copy link
Contributor

njnes commented Apr 7, 2024

@njnes njnes modified the milestones: NEXTFEATURERELEASE, NEXTRELEASE Apr 7, 2024
@njnes njnes self-assigned this Apr 7, 2024
@njnes njnes added the bug Something isn't working label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants