CS257
Chris Pollett
Oct 28, 2020
SELECT title, birthdate FROM MovieStar, StarsIn WHERE year =1996 AND gender='F' AND starName = 'Starlet'

explain select * from my_table order by b asc;which produces
+----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+----------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+----------------+ | 1 | SIMPLE | my_table | NULL | ALL | NULL | NULL | NULL | NULL | 3 | 100.00 | Using filesort | +----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+----------------+ 1 row in set, 1 warning (0.00 sec)
Ex 4 2 5 1 6 3 (runs length 1) 2 4 1 5 3 6 (runs length 2) 1 2 4 5 3 6 (runs length 4) 1 2 3 4 5 6 (runs of length 8) -- done
How much more efficient is this last idea than just merging two blocks?
For each s in S do
    For each r in R do
        if r and s join make a tuple t then output t;
For each M-1 blocks of S do begin
    Read these blocks into main-memory buffers;
    Organize their tuples into a structure whose search
        attributes are the common attributes of R and S;
    For each block b of R do begin
        For each tuple t of b do begin
            find the tuples of S in main memory that join with t;
            output the join of t with each of these tuples;
        end;
    end;
end;
Given `R` we sort `R` and output distinct values.