Welcome Guest, Not a member yet? Register   Sign In
Site Is So Slow!
#5

[eluser]Jay Logan[/eluser]
OK so 1 page that appears to run particularly slow is a page that shows all the events for a meet and counts how many athletes are participating in that event. Some meets have 40 events or more so I would imagine that kind of query could tax my server a bit. Is there any obvious bad practice with the code I use below for my model?


Code:
function get_events_extended($meet_id, $coach_id)
    {
        
        $result = $this->db->query(
            "SELECT Meet_Event.*, Event.*, COUNT(Meet_Athlete.id) AS Total, ".
                "COUNT(Coach.id) AS Coach ".
                "FROM meet_events AS Meet_Event ".
                "LEFT JOIN events AS Event ".
                    "ON Meet_Event.event_id = Event.id ".
                "LEFT JOIN meet_athletes AS Meet_Athlete ".
                    "ON Meet_Event.id = Meet_Athlete.meet_event_id ".
                "LEFT JOIN athletes AS Athlete ".
                    "ON Meet_Athlete.athlete_id = Athlete.id ".
                "LEFT JOIN roster AS Roster ".
                    "ON Roster.athlete_id = Athlete.id ".
                "Left Join coaches AS Coach ".
                    "ON Roster.coach_id = Coach.id AND Coach.id = ? ".
                "WHERE Meet_Event.meet_id = ? ".
                "GROUP BY Meet_Event.id ".
                "ORDER BY Event.type DESC, Event.name ASC, Meet_Event.gender ASC",
            array(
                $coach_id,
                $meet_id
            )
        );
        return $this->clean_result($result);
    }


Messages In This Thread
Site Is So Slow! - by El Forum - 01-09-2009, 08:20 AM
Site Is So Slow! - by El Forum - 01-09-2009, 10:47 AM
Site Is So Slow! - by El Forum - 01-09-2009, 02:10 PM
Site Is So Slow! - by El Forum - 01-09-2009, 03:23 PM
Site Is So Slow! - by El Forum - 01-12-2009, 09:02 AM
Site Is So Slow! - by El Forum - 01-12-2009, 09:30 AM
Site Is So Slow! - by El Forum - 01-12-2009, 10:23 AM
Site Is So Slow! - by El Forum - 01-12-2009, 10:27 AM
Site Is So Slow! - by El Forum - 01-12-2009, 11:46 AM
Site Is So Slow! - by El Forum - 01-12-2009, 11:58 AM
Site Is So Slow! - by El Forum - 01-12-2009, 12:04 PM
Site Is So Slow! - by El Forum - 01-12-2009, 12:10 PM
Site Is So Slow! - by El Forum - 01-12-2009, 12:36 PM
Site Is So Slow! - by El Forum - 01-12-2009, 12:55 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:02 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:03 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:03 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:06 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:09 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:16 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:17 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:23 PM
Site Is So Slow! - by El Forum - 01-12-2009, 01:35 PM
Site Is So Slow! - by El Forum - 01-12-2009, 02:07 PM
Site Is So Slow! - by El Forum - 01-12-2009, 03:52 PM
Site Is So Slow! - by El Forum - 01-12-2009, 04:28 PM
Site Is So Slow! - by El Forum - 01-12-2009, 05:00 PM
Site Is So Slow! - by El Forum - 01-12-2009, 05:28 PM
Site Is So Slow! - by El Forum - 01-12-2009, 05:45 PM
Site Is So Slow! - by El Forum - 01-12-2009, 06:20 PM
Site Is So Slow! - by El Forum - 01-12-2009, 06:47 PM
Site Is So Slow! - by El Forum - 01-12-2009, 07:21 PM
Site Is So Slow! - by El Forum - 01-12-2009, 09:38 PM
Site Is So Slow! - by El Forum - 01-13-2009, 03:22 AM
Site Is So Slow! - by El Forum - 01-13-2009, 04:13 AM
Site Is So Slow! - by El Forum - 01-13-2009, 06:14 AM
Site Is So Slow! - by El Forum - 01-13-2009, 07:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB