I have a MySQL query to pull daily results from gravity forms submissions. However the table is now over 1,000,000 rows and the queries are taking a long time. I need to retain the historical data but is there a way to speed up the below query to skip until row 1000000 from the start?
I am a bit of hack with SQL queries, so any other tips to speed this up is appreciated!.. Much thanks
"SELECT code,Employee_Codes.entry_id FROM {$wpdb->prefix}gf_entry E,
(SELECT form_id, entry_id, meta_value AS code FROM {$wpdb->prefix}gf_entry_meta WHERE meta_key='70')
Employee_Codes,
(SELECT form_id, entry_id, meta_value AS company_id FROM {$wpdb->prefix}gf_entry_meta WHERE meta_key='71')
Company_IDs WHERE E.id=Employee_Codes.entry_id AND Company_IDs.entry_id=E.id AND
Company_IDs.company_id='{$company_id}' AND
E.date_created >='" . date("Y-m-d 00:00:00") . "' AND
E.date_created <= '" . date('Y-m-d 23:59:59') . "' AND Employee_Codes.form_id={$form_id}"