stored procedure mysql

Shriwer

New Member
I have a database call that i am not sure if i am doing it the most efficient way. Basically the call queries a table of events with zip codes and then joins a zip code database that gives the lat/lon of that events zip. Then it joins the logged in user to the query and that user has a lat/lon of upon logging in. So the whole query pulls events from within so many miles of of the users lat/lon.My question, is there a better way to do it then calling this query each time the page is loaded? would a stored procedure be faster? I dont have any experience with them. I am using MySQL.\[code\] $this->db->select('*');$this->db->from('events');$this->db->join('zipcodes', 'zipcodes.zipcode = courses.courseZip');$this->db->join('eventTypes', 'eventTypes.eventTypeID = events.eventType');$this->db->where('eventApproved', 1);$this->db->select('(DEGREES(ACOS(SIN(RADIANS('.$this->user['userLat'].')) * SIN(RADIANS(latitude)) + COS(RADIANS('.$this->user['userLat'].')) * COS(RADIANS(latitude)) * COS(RADIANS('.$this->user['userLon'].' - longitude))))) * 69.09 AS distance');$this->db->having('distance <', 100);\[/code\]
 
Back
Top