title: Query performance issue with ST_Intersects()
body: <p>Following query is taking 3.06min to execute. How to speedup this query? How to use existing index column while executing query?</p>
  
  <pre><code>SELECT samples_collected.talukname,sample_count,TotalSamples from 
  (
  SELECT a.talukname talukname, COUNT (DISTINCT b.globalid) sample_count
  FROM village a, gridpoint_1 b ,gridpoint_1__attach c
  WHERE  st_intersects(a.shape,b.shape)
  and b.globalid=c.rel_globalid
  and  a.districtname='Bagalkot'
  GROUP BY a.talukname
  ) samples_collected,
  (
  SELECT a.talukname talukname,COUNT (DISTINCT b.globalid) TotalSamples
  FROM village a
  INNER JOIN
  gridpoint_1 b ON  st_intersects(a.shape,b.shape)
  WHERE a.districtname='Bagalkot'
  GROUP BY a.talukname
  ) total
  WHERE samples_collected.talukname=total.talukname;
  </code></pre>