Hi everybody.
I often try to parametrize out my queries as much as possible with user-variables. So, say you have a general query for all users:
--- SELECT ... FROM users ---
It's nice to do this:
---- SET @USER_ID:= NULL; SELECT ... FROM users WHERE IF(@USER_ID IS NOT NULL,[EMAIL PROTECTED],1) ---
This *works*, but when you set @USER_ID to a variable, the 4.1 optimizer doesn't optimize it very well: it does a table-scan, instead of using the index on user_id.
Has anyone got a good alternative that will do less table-scans?
Or, if a developer is listening, can you give us details on how the optimizer deals with IF()?
Thanks.
Tom.
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]