Welcome Guest, Not a member yet? Register   Sign In
$this->db->having() makes my query a bit slow
#3

[eluser]kgill[/eluser]
The reason it's slowing way down is that "having" is normally used for filtering aggregate functions eg. you sum'd a column and only want the records where the sum is greater than X, that can't be done in a where clause so it has to be done after the completed record set is built. Using is not null in a having clause means the DB first selects the entire record set based on your where clause then it has to go back over it and search for nulls. Instead you should be sticking that "is not null" in the where clause to limit the data while it's being selected: $this->db->where('field is not null')

- K


Messages In This Thread
$this->db->having() makes my query a bit slow - by El Forum - 11-29-2007, 09:06 AM
$this->db->having() makes my query a bit slow - by El Forum - 11-29-2007, 02:29 PM
$this->db->having() makes my query a bit slow - by El Forum - 11-29-2007, 03:12 PM
$this->db->having() makes my query a bit slow - by El Forum - 11-29-2007, 03:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB