title: Difference between performance of the two sql queries?
body: <p>I have a field in my table having text data type.</p>
  
  <p>Is there a difference in performance for the following two sql queries:</p>
  
  <pre><code> select * from tablename where fieldname="xyz%";
   select * from tablename where fieldname="%zyx";
  </code></pre>
  
  <p>If we were to implement the execution of these queries, this is what I think we would need to do:</p>
  
  <p>We have to match the two regexes (xyz* and *zyx).</p>
  
  <p>We will have to check the string chars one by starting from the beginning.</p>
  
  <p>For the first query we will have to read the first three characters to see if there is a match but for the second one we will have to read till the we get the end of the string to determine if the match has occurred. But if we have the length of the string stored somewhere we can directly read the last three characters giving similar performance as the first case.</p>
  
  <p>My question is whether commercial databases like mysql and oracle show any difference in the performance in the execution of the queries.</p>