title: Effectively query on column that includes a substring
body: <p>Given a string column with a value similar to <code>/123/12/34/56/5/</code>, what is the optimal way of querying for all the <strong>records that include the given number</strong> (<code>12</code> for example)?</p>
  
  <p>The solution from top of my head is:</p>
  
  <p><code>
  SELECT id FROM things WHERE things.path LIKE '%/12/%'
  </code></p>
  
  <p>But AFAIK this query can't use indexes on the column due to the leading <code>%</code>.  </p>
  
  <p>There must be something better. What is it?</p>
  
  <p>Using PostgreSQL, but would <em>prefer</em> the solution that would work across other DBs too.</p>