title: mysql show table / columns - performance question
body: <p>I'm working on a basic php/mysql CMS and have a few questions regarding performance.</p>
  
  <p>When viewing a blog page (or other sortable data) from the front-end, I want to allow a simple 'sort' variable to be added to the querystring, allowing posts to be sorted by any column. Obviously I can't accept <em>anything</em> from the querystring, and need to make sure the column exists on the table.</p>
  
  <p>At the moment I'm using</p>
  
  <pre><code>SHOW TABLES;
  </code></pre>
  
  <p>to get a list of all of the tables in the database, then looping the array of table names and performing</p>
  
  <pre><code>SHOW COLUMNS;
  </code></pre>
  
  <p>on each.</p>
  
  <p>My worry is that my CMS might take a performance hit here. I thought about using a static array of the table names but need to keep this flexible as I'm implementing a plugin system.</p>
  
  <p>Does anybody have any suggestions on how I can keep this more concise?</p>
  
  <p>Thankyou</p>