Hey,
I see that the CExistValidator selects a field in order to determine if the specified piece of data exists in the given table.
Everyone knows a COUNT() is faster than selecting a field, so why are you not selecting a COUNT() and comparing it?
e.g.
SELECT COUNT(*) FROM user WHERE username = 'Somename'
vs
SELECT id FROM user WHERE username = 'Somename'
In the COUNT query, you simply check if the result is more than 0.
It is much, much faster than selecting a field for absolutely no reason.
Page 1 of 1
CExistValidator Excessive Query
#2
Posted 23 June 2010 - 02:36 PM
I've looked at it very briefly and the problem (if there is a problem) is at CActiveRecord::exists.
There is EXISTS in SQL so maybe we should consider using it.
Please create an issue so we'll not forget to analyze it: http://code.google.c...ii/issues/entry
There is EXISTS in SQL so maybe we should consider using it.
Please create an issue so we'll not forget to analyze it: http://code.google.c...ii/issues/entry
Share this topic:
Page 1 of 1

Help












