title: Speed of SELECT Distinct vs array unique
body: <p>I am using WordPress with some custom post types (just to give a description of my DB structure - its WP's).</p>
  
  <p>Each post has custom meta, which is stored in a separate table (postmeta table). In my case, I am storing city and state.</p>
  
  <p>I've added some actions to WP's save_post/trash_post hooks so that the city and state are also stored in a separate table (cities) like so:</p>
  
  <pre><code> ID    postID    city      state
  auto    int     varchar   varchar
  </code></pre>
  
  <p>I did this because I assumed that this table would be faster than querying the rather large postmeta table for a list of available cities and states.</p>
  
  <p>My logic also forced me to add/update cities and states for every post, even though this will cause duplicates (in the city/state fields). This must be so because I must keep track of which states/cities exist (actually have a post associated with them). When a post is added or deleted, it takes its record to or from the cities table with it.</p>
  
  <p>This brings me to my question(s).<br /></p>
  
  <ol>
  <li>Does this logic make sense or do I suck at DB design?</li>
  <li>If it does make sense, my real question is this: **would it be faster to use MySQL's "SELECT DISTINCT" or just "SELECT *" and then use PHP's array_unique on the results?**</li>
  </ol>
  
  <p><strong>Edits for comments/answers thus far:</strong><br />
  The structure of the table is exactly how I typed it out above. There is an index on ID, but the point of this table isn't to retrieve an indexed list, but to retrieve ALL results (that are unique) for a list of ALL available city/state combos.</p>
  
  <p><strong>I think I may go with (I don't know why I didn't think of this before) just adding a serialized list of city/state combos in ONE record in the wp_options table. Then I can just get that record, and filter out the unique records I need. 
  Can I get some feedback on this?</strong> I would imagine that retrieving and filtering a serialized array would be faster than storing the data in a separate table for retrieval.</p>