php - MYSQL Inner Join speed issue -
i have been having mega issues query.
it's file that's run cron every 24 hours , runs conditional checks against members in database.
apparently crashes mysql server (takes 2 hours execute?).
every table has primary keys set on rows foo_id & foo_uid joins indexed under primary , such should speed.
please help, killing me.
$members = new wa_mysqli_rs("members", $alpha, 1); $members->setquery("select registration.*, child_base_survey.*, child_base_scas.*, child_base_smqf.*, parent_base_survey.*, parent_base_ippa.*, parent_base_eac.*, parent_base_scas.*, parent_base_smqf.*, parent_base_eval.*, user_access_level.*, parent_one_month_survey.*, parent_one_month_ippa.*, parent_one_month_eac.*, parent_one_month_eval.*, child_three_month_survey.*, child_three_month_scas.*, child_three_month_smqf.*, parent_three_month_survey.*, parent_three_month_scas.*, parent_three_month_smqf.*, parent_three_month_eval.*, cron.* registration inner join child_base_survey on registration.rego_parent_uid = child_base_survey.child_base_survey_uid inner join child_base_scas on child_base_survey.child_base_survey_uid = child_base_scas.child_base_scas_uid inner join child_base_smqf on child_base_scas.child_base_scas_uid = child_base_smqf.child_base_smqf_uid inner join parent_base_survey on child_base_smqf.child_base_smqf_uid = parent_base_survey.parent_base_survey_uid inner join parent_base_ippa on parent_base_survey.parent_base_survey_uid = parent_base_ippa.parent_base_ippa_uid inner join parent_base_eac on parent_base_ippa.parent_base_ippa_uid = parent_base_eac.parent_base_eac_uid inner join parent_base_scas on parent_base_eac.parent_base_eac_uid = parent_base_scas.parent_base_scas_uid inner join parent_base_smqf on parent_base_scas.parent_base_scas_uid = parent_base_smqf.parent_base_smqf_uid inner join parent_base_eval on parent_base_smqf.parent_base_smqf_uid = parent_base_eval.parent_base_eval_uid inner join user_access_level on parent_base_eval.parent_base_eval_uid = user_access_level.user_access_level_uid inner join parent_one_month_survey on user_access_level.user_access_level_uid = parent_one_month_survey.parent_one_month_survey_uid inner join parent_one_month_ippa on parent_one_month_survey.parent_one_month_survey_uid = parent_one_month_ippa.parent_one_month_ippa_uid inner join parent_one_month_eac on parent_one_month_ippa.parent_one_month_ippa_uid = parent_one_month_eac.parent_one_month_eac_uid inner join parent_one_month_eval on parent_one_month_eac.parent_one_month_eac_uid = parent_one_month_eval.parent_one_month_eval_uid inner join child_three_month_survey on parent_one_month_eval.parent_one_month_eval_uid = child_three_month_survey.child_three_month_survey_uid inner join child_three_month_scas on child_three_month_survey.child_three_month_survey_uid = child_three_month_scas.child_three_month_scas_uid inner join child_three_month_smqf on child_three_month_scas.child_three_month_scas_uid = child_three_month_smqf.child_three_month_smqf_uid inner join parent_three_month_survey on child_three_month_smqf.child_three_month_smqf_uid = parent_three_month_survey.parent_three_month_survey_uid inner join parent_three_month_scas on parent_three_month_survey.parent_three_month_survey_uid = parent_three_month_scas.parent_three_month_scas_uid inner join parent_three_month_smqf on parent_three_month_scas.parent_three_month_scas_uid = parent_three_month_smqf.parent_three_month_smqf_uid inner join parent_three_month_eval on parent_three_month_smqf.parent_three_month_smqf_uid = parent_three_month_eval.parent_three_month_eval_uid inner join cron on parent_three_month_eval.parent_three_month_eval_uid = cron.cron_uid registration.rego_parent_uid = ?"); $members->bindparam("s", "" . ((isset($_session["rego_parent_uid"])) ? $_session["rego_parent_uid"] : "") . "", "-1"); //waqb_param1 $members->execute(); ?>
run them separate queries, cursory glance, looks joining every possible table data associated reference id value. results going cross product of every matching row in each table. n tables, each row in table x repeated r0*r1*r2*....rx-1*rx+1*...rn. 23 tables there, if each had 2 rows, you'd have 8.4 million rows in results.
Comments
Post a Comment