SQL Optimisation Commit for zzzzsys_tab
Posted: Thu Dec 24, 2020 9:42 am
The effective change in the recent commit apart from a slate of whitespace changes have changed the following SQL:
to:
The major change here is to restrict the resultset into keeping just one tables' fields instead of those from both but I wonder what the "ORDER by sy_order" really does since many are of the same order value.
The following may be a better bet considering optimisation:
Code: Select all
SELECT *
FROM zzzzsys_tab
INNER JOIN zzzzsys_object ON sob_all_zzzzsys_form_id = syt_zzzzsys_form_id
WHERE syt_zzzzsys_form_id = '$i'
GROUP BY syt_zzzzsys_form_id, syt_title
ORDER BY syt_order;
Code: Select all
SELECT DISTINCT zzzzsys_tab.*
FROM zzzzsys_tab
INNER JOIN zzzzsys_object ON sob_all_zzzzsys_form_id = syt_zzzzsys_form_id
WHERE syt_zzzzsys_form_id = '$i'
ORDER BY syt_order;
The following may be a better bet considering optimisation:
Code: Select all
SELECT zzzzsys_tab.*
FROM zzzzsys_tab
INNER JOIN zzzzsys_object ON sob_all_zzzzsys_form_id = syt_zzzzsys_form_id
GROUP BY `zzzzsys_tab_id`, `syt_zzzzsys_form_id`
HAVING syt_zzzzsys_form_id = '$i';