// Moved a condition/function from SQL to PHP.
// Added a more efficient index