So...I have a large list of points (~30,000). I need to count the number of points that overlap a polygon (or multiple polyongs e.g. 100's). Each polygon represents part of a grid that overlaps the envelope of the list of points, so I need to know the count of points per grid cell. <br>

<br>Currently I can generate each grid cell "in memory" and feed them  to a query using ST_GeomFromText. Now, I know this takes a long time to complete and is not optimal.<br><br>I would like any opinions as to what the best solution to implementing the query would be. I am thinking along the lines of generating the full grid as a table with either each cell stored separately or the whole grid as a single multipolygon and then performing the ST_Intersects part of the query.<br>
<br>And also I know I should generate an index to help the query planning/search.<br><br>Thanks<br clear="all"><br>-- <br>Thanks,<br>Louis<br>
<div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">
</div>
<div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>