如何优化这个临时表查询?

I have written a stored procedure that takes comma separated value as input and another value. I traverse values from comma separated value and then run a query for each value. now I need to return result so I thought to store results in temporary table and then selected values from that temporary table.But it is taking too long.

for query with 163 comma separated values it is taking 7 seconds. for query with 295 comma separated values it is taking 12 seconds.

Here is procedure:-

DELIMITER $
create procedure check_fbid_exists(IN myArrayOfValue TEXT, IN leaderID INT(11) ) 
BEGIN

DECLARE status TINYINT(1);
DECLARE value INT(11);
DECLARE pos int(11);

CREATE TEMPORARY TABLE fbid_exists_result (userID int(11), status tinyint(1));
WHILE (CHAR_LENGTH(myArrayOfValue) > 0)
DO
 SET pos=LOCATE(  ',', myArrayOfValue);

IF pos>0 THEN
SET value = LEFT(  myArrayOfValue,pos-1 );
SET myArrayOfValue= SUBSTRING( myArrayOfValue,pos+1 );                                                                                                    
ELSE
SET value = myArrayOfValue;
  SET myArrayOfValue='';
 END IF;

 SELECT EXISTS(SELECT 1 FROM users_followings WHERE UserID=value and       LeaderUserID=leaderID LIMIT 1) INTO status;
     insert into fbid_exists_result VALUES(value,status); 


  END WHILE;
 SELECT * FROM  fbid_exists_result ; 
DROP TEMPORARY TABLE IF EXISTS fbid_exists_result ;       

 END$