/*CREATE INDEX*/
create index population on city(population);

create unique index phone on address(phone);
/*lIST ON INDEXIS*/
show index from address;

/*gENERATION ROWS*/
CREATE PROCEDURE dowhile()
BEGIN
  DECLARE v1 INT DEFAULT 1000;

  WHILE v1 > 0 DO
    INSERT INTO TAB1(sNAME, DATEbIRTH, KILKIST)
    VALUES ('aa'+CAST(VA1 AS VARCHAR(3)), CURDatE(), floor(RAND()*10))
    SET v1 = v1 - 1;
  END WHILE;
END;

/*ANALYSIS OF USING INDEXES*/
use sakila;
explain select * from actor inner join film_actor 
					on actor.actor_id = film_actor.actor_id 
					join film on film.film_id=film_actor.film_id;
                                    
explain select * from film where film.title like '%a%';


/* SLOW LOG ON*/
show variables like '%slow%';

set global slow_query_log=1;


set global slow_query_log_file = 'd:\slowQuery.log';


show variables like '%slow%';
/*PROFILYNG*/
set profiling=1;
select * from actor
where actor_id = 2;

SELECT * FROM information_schema.PROFILING;
select state, count(*), format(sum(duration),6) as
duration
from information_schema.PROFILING
where QUERY_ID = 1 group by state;
