Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow query which crashes mysql #721

Closed
tbar0970 opened this issue Sep 6, 2021 · 0 comments
Closed

Slow query which crashes mysql #721

tbar0970 opened this issue Sep 6, 2021 · 0 comments
Labels

Comments

@tbar0970
Copy link
Owner

tbar0970 commented Sep 6, 2021

Attendance display
format=tabular
for several years

Probably the left-join onto a subquery is the killer.
Can this be avoided??

SELECT person.id, person.last_name, person.first_name,  person.status, ar.date, ar.present
				FROM person person
				JOIN age_bracket ab ON ab.id = person.age_bracketid
				JOIN family f ON person.familyid = f.id
				
				LEFT JOIN (
					SELECT personid, date, present
					FROM attendance_record ar
					WHERE ar.date BETWEEN '2006-01-02' AND '2012-01-01'
					AND ar.groupid = 0
				) ar ON ar.personid = person.id
				WHERE ((person.status <> "archived") OR (ar.present IS NOT NULL)) 
				 AND person.congregationid IN ('6') 
				ORDER BY person.status ASC, family_name ASC, familyid, ab.rank ASC, gender DESC

BACKTRACE:
Array
(
    [0] => Array
        (
            [file] => /home/jethro/code/2.30.1/db_objects/attendance_record_set.class.php
            [line] => 741
            [function] => query
            [class] => PDO
            [type] => ->
            [args] => Array
                (
                    [0] => SELECT person.id, person.last_name, person.first_name,  person.status, ar.date, ar.present
				FROM person person
				JOIN age_bracket ab ON ab.id = person.age_bracketid
				JOIN family f ON person.familyid = f.id
				
				LEFT JOIN (
					SELECT personid, date, present
					FROM attendance_record ar
					WHERE ar.date BETWEEN '2006-01-02' AND '2012-01-01'
					AND ar.groupid = 0
				) ar ON ar.personid = person.id
				WHERE ((person.status <> "archived") OR (ar.present IS NOT NULL)) 
				 AND person.congregationid IN ('6') 
				ORDER BY person.status ASC, family_name ASC, familyid, ab.rank ASC, gender DESC
                )

        )

    [1] => Array
        (
            [file] => /home/jethro/code/2.30.1/views/view_6_attendance__2_display.class.php
            [line] => 361
            [function] => getAttendances
            [class] => Attendance_Record_Set
            [type] => ::
            [args] => Array
                (
                    [0] => [Object/Array]
                    [1] => [Object/Array]
                    [2] => [Object/Array]
                    [3] => 2006-01-02
                    [4] => 2012-01-01
                )

        )

    [2] => Array
        (
            [file] => /home/jethro/code/2.30.1/views/view_6_attendance__2_display.class.php
            [line] => 73
            [function] => _printResultsTabular
            [class] => View_Attendance__Display
            [type] => ->
            [args] => Array
                (
                )

        )

    [3] => Array
        (
            [file] => /home/jethro/code/2.30.1/include/system_controller.class.php
            [line] => 186
            [function] => printView
            [class] => View_Attendance__Display
            [type] => ->
            [args] => Array
                (
                )

        )

@tbar0970 tbar0970 added the bug label Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant