title: MySQL - Fast query but slow Stored Procedures
body: <p>I know this question has been discussed quite a lot <a href="https://stackoverflow.com/questions/440944/sql-server-query-fast-but-slow-from-procedure">here</a>. But I have a particular case when I need to pass a list of parameters (comma - separated) which prevents me to have a local variable declared and used for input parameter.</p>
  
  <p>As pointed out in the above discussion, it is suggested to declare a local variable and assign the parameters to this variable. However, what should I do in case my parameter is of type <code>Text</code> and can be comma - separated list?</p>
  
  <p>For example - </p>
  
  <pre><code>CREATE DEFINER=`Admin`@`%` PROCEDURE `MyReport`(
      p_myparameter_HK Text
  )
  BEGIN
  SELECT
  *
  FROM MyTable
  WHERE 
  (find_in_set(MyTable.column_HK, p_myparameter_HK) &lt;&gt; 0 OR MyTable.column_HK IS NULL)
  ;
  
  END
  </code></pre>
  
  <p>Performance:</p>
  
  <blockquote>
    <p>Query</p>
  </blockquote>
  
  <p>If I just run the query - 300 ms</p>
  
  <blockquote>
    <p>Stored Procedure</p>
  </blockquote>
  
  <pre><code>CALL MyReport('0000_abcd_fake_000')
  </code></pre>
  
  <p>This procedure keeps running endlessly.</p>
  
  <p>My question is, how can I disable <code>parameter sniffling</code> and use local variable instead of <code>find_in_set</code> to match the query performance.</p>