title: how to increase performance of mysql query?
body: <p>I'm using this query to check the username is already exist or not in database using ajax
  so till now i hv only few records in DB bt in future username list gonna be huge so i want to improve the performance of query in such a way it will take less time to check username existence.</p>
  
  <p>how can i improve following query ? is indexing on db is feasible solution for this ?</p>
  
  <pre><code>check.php
  
  &lt;?php
  if(isset($_POST['user_name']))
  {
  $user_name=$_POST['user_name'];
  include("include/conn.php");
  $sql_check = mysql_query("select userid from `vector`.`signup` where userid='".$user_name."'")
   or die(mysql_error());
  
  if (mysql_num_rows($sql_check)&gt;0)
  {   
      echo "no";
  } 
  else
  {
   echo "yes";
  }
  }
  ?&gt; 
  
  my jquery code 
  
  &lt;script language="javascript"&gt;
  
  $(document).ready(function()
  {
      $("#uname").blur(function()
      {
                  $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
  
          $.post("check.php",{ user_name:$(this).val() } ,function(data)
          {
            if(data=='no') //if username not avaiable
            {
              $("#msgbox").fadeTo(200,0.1,function() 
              { 
  
                $(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
              });     
            }
            else
            {
              $("#msgbox").fadeTo(200,0.1,function()  
              { 
  
                $(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);    
              });
            }
  
          });
  
      });
  });
  &lt;/script&gt;
  </code></pre>