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

Study Q6 #7

Open
wukefe opened this issue Aug 25, 2017 · 0 comments
Open

Study Q6 #7

wukefe opened this issue Aug 25, 2017 · 0 comments

Comments

@wukefe
Copy link
Contributor

wukefe commented Aug 25, 2017

MonetDB MAL details (An Example from TPC-H Q6)

Code snippet

SQL code

  select
    sum(l_extendedprice * l_discount) as revenue
  from
    lineitem
  where
    l_shipdate >= date '1994-01-01'
    and l_shipdate < date '1994-01-01' + interval '1' year
    and l_discount between .06 - 0.01 and .06 + 0.01
    and l_quantity < 24; 

MAL code (for WHERE)

...
|     X_137:bat[:lng] := sql.bind(X_3,"sys","lineitem","l_discount",0:int,0:int,8:int);   |
...
|     C_114:bat[:oid] := sql.tid(X_3,"sys","lineitem",0:int,8:int);                       |
|     X_48:date := mtime.addmonths("1994-01-01":date,12:int);                             |
|     C_171 := algebra.subselect(X_147,C_114,"1994-01-01":date,X_48,true,false,false);    |
|     C_179 := algebra.subselect(X_137,C_171,5:lng,7:lng,true,true,false);                |
|     C_187 := algebra.thetasubselect(X_129,C_179,2400:lng,"<");                          |

Details

  • mtime.addmonths: returns a new date by adding months
  • algebra.subselect: selects items by a boolean mask ()
  • algebra.thetasubselect: see source code

Remaining questions

  1. Why floating point literals in the query multiply by 100 to convert to a long int type? Any performance concerns?
    • The column discount is treated as a long int column.
  2. Why does the MAL code have to repeat 8 times? (Hint: 8 threads?)
    • I made some efforts to figure out the meaning of each parameter in sql.bind
    • I searched on the MonetDB GitHub repo, but failed to identify where the source code was
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant