here is Livi I am working on project in which database is too much huge and i have fear that db query optimization must be done there. I am working on DB and it has almost billions of records in tables and i am searching fast method which consume less resoureces from database server and web server. At the time, i am using 2 queries to select data from tables like
result1 = select data_id from table1 where id<1000
and than by using php code i fetch data and than again run query to fetch data like
select * from table2 where data_id1<result1
and i can also use this as sub query.
i have question that which method will be best for me as i told that it have very big database could be in GB's.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `table2` ADD INDEX `table2_idx_data_id1` (`data_id1`);
SELECT
*
FROM
table2
WHERE
table2.data_id1 < table2.result1