.timer on

select * from movie where id=5 limit 1;
select * from movie where id=538121 limit 1;

select count(*) from actor;
-- 107489 / 0.058
-- 629407 / 0.015


select dob from actor where name = 'Carrie Fisher';
-- 0.173
-- 0.504
create index i1 on actor(name);
-- 0.001
-- 0.001

select count(*) from actor where dob between '1960-01-01' and '1970-12-31';
-- 0.172
-- 0.5
create index i2 on actor(dob);
-- 0.006
-- 0.013


select count(*) from movie where release_date between '2000-01-01' and '2000-12-31';
-- Run Time: real 0.025 user 0.023446 sys 0.000588
-- Run Time: real 0.712 user 0.528962 sys 0.181995
-- 10000 / 309063
create index i3 on movie(release_date);
-- 0.001
-- 0.004

select count(*) from director where dob between '1960-01-01' and '1970-12-31'; 
-- 4572 / 90444
-- Run Time: real 0.019 user 0.016482 sys 0.001162
-- Run Time: real 0.071 user 0.048670 sys 0.022205





select count(title) from movie, director where movie.director_id = director.id and director.name='Steven Spielberg';
-- 0.09
-- 7.75
create index i4 on director(name);
-- 0.028
-- 0.458
create index i5 on movie(director_id);
-- 0.001
-- 0.001

select title from movie, star, actor where movie.id = star.movie_id and star.actor_id = actor.id and actor.name = 'Harrison Ford';
--  2.731
-- 56.367
create index i6 on actor(name);
-- 2.5
-- 54.104
create index i7 on star(actor_id);
-- 0.079
-- 2.585
create index i8 on movie(id);
-- 0.005
-- 0.006



select count(distinct m.title) 
from actor c, star s1, movie m, star s2, actor a 
where c.name = 'Carrie Fisher' and s1.actor_id = c.id and s1.movie_id = m.id  and m.id = s2.movie_id and s2.actor_id = a.id;
--  5.001
-- 89.240

create index i9 on actor(name);
create index i10 on star(movie_id);
create index i11 on movie(id);
create index i12 on actor(id);

-- 0.018
-- 0.048



create table film (titre text, budget real, synopse text, langue text);

insert into film select title, budget, overview, language from movie;
-- 0.4
-- 4.9 ~ 10
delete from film;
-- 0.5
-- 11.0

create index i13 on film(titre);

insert ...
-- 0,5
-- 11.284

delete from film;
-- 0.9
-- 13.09

create index i14 on film(budget);
-- 0.679
-- 1.87

delete from film;
-- 0.56
-- 14.234

create index i15 on film(synopse);
insert ..

-- 1.032
-- 52.360

drop.. create.. insert
create index i15 on film (synopse);
-- 1.019
-- 15.537

drop.. create.. index.. insert
-- 0.7
-- 38.346

