/******************************************************************************
 * For generating the query plans for the various queries
 ******************************************************************************/
-- Q1:
EXPLAIN PLAN SET statement_id = 'Q1a' FOR
SELECT unique2 FROM r2 s WHERE s.unique1=8530;

EXPLAIN PLAN SET statement_id = 'Q1b' FOR
SELECT unique2 FROM r2 s WHERE s.unique3=8530;

-- Q2:
EXPLAIN PLAN SET statement_id = 'Q2a' FOR
SELECT AVG(unique2) FROM r2 s WHERE s.unique1 > 1000;

EXPLAIN PLAN SET statement_id = 'Q2b' FOR
SELECT AVG(unique2) FROM r2 s WHERE s.unique3 > 1000;

-- Q3:
EXPLAIN PLAN SET statement_id = 'Q3a' FOR
SELECT AVG(unique1) FROM r2 s WHERE s.unique1 BETWEEN 200 AND 900;

EXPLAIN PLAN SET statement_id = 'Q3b' FOR
SELECT AVG(unique1) FROM r2 s WHERE s.unique3 BETWEEN 200 AND 900;

-- Q4:
EXPLAIN PLAN SET statement_id = 'Q4a' FOR
SELECT AVG(r.four+s.four) FROM r1 r, r2 s
WHERE r.unique1=s.unique1 AND s.unique1=8530 AND r.unique1 > 200;

EXPLAIN PLAN SET statement_id = 'Q4b' FOR
SELECT AVG(r.four+s.four) FROM r1 r, r2 s
WHERE r.unique3=s.unique3 AND s.unique3=8530 AND r.unique3 > 200;

-- Q5
EXPLAIN PLAN SET statement_id = 'Q5a' FOR
SELECT COUNT(*) from r1 r, r2 s
WHERE r.unique1=s.unique1 AND r.unique1 > 700;

EXPLAIN PLAN SET statement_id = 'Q5b' FOR
SELECT COUNT(*) from r1 r, r2 s
WHERE r.unique3=s.unique3 AND r.unique3 > 700;

