title: q-gram approximate matching optimisations
body: <p>I have a table containing 3 million people records on which I want to perform fuzzy matching using q-grams (on surname for instance). I have created a table of 2-grams linking to this, but search performance is not great on this data volume (around 5 minutes).</p>
  
  <p>I basically have two questions:
  (1) Can you suggest any ways to improve performance to avoid a table scan (i.e. having to count common q-grams between the search string and 3 million surnames)
  (2) With q-grams, if A is similar to B and C is similar to B, does it imply C is similar to A?</p>
  
  <p>Kind regards</p>
  
  <p>Peter</p>