query optimization
note
- join is expensive!
- want to apply it to small tables whereever possible
- could have done one of the selects before the join first
- instead of
select SPONSOR from
filter EVENT = java-jump
filter CAFEMEISTER = NAME from
join EVENTS and ATHLETES
- we could write
select SPONSOR from
filter CAFEMEISTER = NAME from
join ATHLETES and
filter EVENT = java-jump from EVENTS
- now join gives table with only 3 rows instead of 9
we’d like
- to write the query either way, and have the database figure out a better way to write it
- this is called query optimization: can be expressed with simple rules