-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze_queries.sql
More file actions
31 lines (26 loc) · 793 Bytes
/
analyze_queries.sql
File metadata and controls
31 lines (26 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--non-nested
explain analyze
select distinct player_id,player_name from participant as p, winner as w
where w.medal = 'Gold'
and p.player_id=w.player_id;
--nested
explain analyze
select distinct player_id,player_name from participant
where player_id in (
select player_id from winner
where medal = 'Gold');
-- select countries that have won gold
-- non-nested
explain analyze
select distinct c.country_id, c.country_name from country as c, participant as p, winner as w
where w.medal = 'Gold'and
c.country_id = p.country_id and
p.player_id = w.player_id;
--
-- nested
explain analyze
select distinct country_id, country_name from country where country_id in (
select p.country_id from participant as p
inner join winner as w
on p.player_id = w.player_id
where w.medal = 'Gold');