<div dir="ltr">Have you tried creating a table with x,y,z fields and creating a functional index for the geometry?</div><div dir="ltr"><br></div><div dir="ltr">Some experiments:</div><div dir="ltr"><br></div><div dir="ltr">
-- populate a table of 1m records, index, cluster and update:</div><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="courier new, monospace">CREATE TABLE lidar_geom</font></div><div dir="ltr"><font face="courier new, monospace">AS SELECT</font></div>
<div dir="ltr"><font face="courier new, monospace">   generate_series(1,1000) as x</font></div><div dir="ltr"><font face="courier new, monospace"> , y</font></div><div dir="ltr"><font face="courier new, monospace"> , (random() * 100)::integer as z</font></div>
<div dir="ltr"><font face="courier new, monospace">FROM</font></div><div dir="ltr"><font face="courier new, monospace">   (SELECT</font></div><div dir="ltr"><font face="courier new, monospace">      generate_series(1,1000) as y</font></div>
<div dir="ltr"><font face="courier new, monospace">   ) AS ys;</font></div><div dir="ltr"><font face="courier new, monospace">CREATE INDEX idx_st_makepoint_x_y_z_lidar_geom ON lidar_geom USING GIST (st_makepoint(x,y,z));</font></div>
<div dir="ltr"><font face="courier new, monospace">CLUSTER idx_st_makepoint_x_y_z_lidar_geom ON lidar_geom;</font></div><div dir="ltr"><font face="courier new, monospace">VACUUM ANALYZE lidar_geom;</font></div></div><div dir="ltr">
<div dir="ltr"><br></div><div dir="ltr">-- check sizes (your numbers may vary):</div><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="courier new, monospace">SELECT pg_size_pretty(pg_total_relation_size('lidar_geom') + pg_total_relation_size('idx_st_makepoint_x_y_z_lidar_geom'));</font></div>
<div dir="ltr">--"155 MB"</div><div><br></div></div></div></div></div><div dir="ltr">-- now, create another table (with the same values as the first) but with a concrete geometry:</div><div dir="ltr"><div dir="ltr">
<font face="courier new, monospace">CREATE TABLE</font></div><div dir="ltr"><font face="courier new, monospace">   lidar_geom_concrete(x,y,z,the_geom) AS</font></div><div dir="ltr"><font face="courier new, monospace">SELECT</font></div>
<div dir="ltr"><font face="courier new, monospace">   x</font></div><div dir="ltr"><font face="courier new, monospace"> , y</font></div><div dir="ltr"><font face="courier new, monospace"> , z</font></div><div dir="ltr"><font face="courier new, monospace"> , st_makepoint(x,y,z)</font></div>
<div dir="ltr"><font face="courier new, monospace">FROM</font></div><div dir="ltr"><font face="courier new, monospace">   lidar_geom;</font></div><div dir="ltr"><font face="courier new, monospace">CREATE INDEX idx_lidar_geom_concrete_the_geom ON lidar_geom_concrete USING GIST (the_geom);</font></div>
<div dir="ltr"><font face="courier new, monospace">CLUSTER idx_lidar_geom_concrete_the_geom ON lidar_geom_concrete;</font></div><div dir="ltr"><font face="courier new, monospace">VACUUM ANALYZE lidar_geom_concrete;</font></div>
<div><br></div><div>-- check sizes:</div><div><div>SELECT pg_size_pretty(pg_total_relation_size('lidar_geom_concrete') + pg_total_relation_size('idx_lidar_geom_concrete_the_geom'));</div><div>--"169 MB"</div>
</div><div><br></div><div><br></div><div>So you win with a decrease in storage.  My numbers for the query planner were all over the place, but my installation isn't tuned. Actual query performance was broadly comparable (within the tolerances of my PC):</div>
<div><br></div><div><div><font face="courier new, monospace">EXPLAIN ANALYZE</font></div><div><font face="courier new, monospace">SELECT</font></div><div><font face="courier new, monospace">   COUNT(*)</font></div><div><font face="courier new, monospace">FROM</font></div>
<div><font face="courier new, monospace">   lidar_geom</font></div><div><font face="courier new, monospace">WHERE</font></div><div><font face="courier new, monospace">   st_intersects(st_makepoint(x,y,z), st_geomfromtext('POLYGON((500 500,500 503,503 503,503 500,500 500))'));</font></div>
</div><div><br></div><div><div>"Aggregate  (cost=25.55..25.56 rows=1 width=0) (actual time=0.593..0.593 rows=1 loops=1)"</div><div>"  ->  Bitmap Heap Scan on lidar_geom  (cost=4.59..25.54 rows=2 width=0) (actual time=0.528..0.586 rows=16 loops=1)"</div>
<div>"        Recheck Cond: (st_makepoint((x)::double precision, (y)::double precision, (z)::double precision) && '010300000001000000050000000000000000407F400000000000407F400000000000407F400000000000707F400000000000707F400000000000707F400000000000707F400000000000407F400000000000407F400000000000407F40'::geometry)"</div>
<div>"        Filter: _st_intersects(st_makepoint((x)::double precision, (y)::double precision, (z)::double precision), '010300000001000000050000000000000000407F400000000000407F400000000000407F400000000000707F400000000000707F400000000000707F400000000000707F400000000000407F400000000000407F400000000000407F40'::geometry)"</div>
<div>"        ->  Bitmap Index Scan on idx_st_makepoint_x_y_z_lidar_geom  (cost=0.00..4.59 rows=5 width=0) (actual time=0.492..0.492 rows=16 loops=1)"</div><div>"              Index Cond: (st_makepoint((x)::double precision, (y)::double precision, (z)::double precision) && '010300000001000000050000000000000000407F400000000000407F400000000000407F400000000000707F400000000000707F400000000000707F400000000000707F400000000000407F400000000000407F400000000000407F40'::geometry)"</div>
<div>"Total runtime: 0.699 ms"</div></div><div><br></div><div><br></div><div><div><font face="courier new, monospace">EXPLAIN ANALYZE</font></div><div><font face="courier new, monospace">SELECT</font></div><div>
<font face="courier new, monospace">   COUNT(*)</font></div><div><font face="courier new, monospace">FROM</font></div><div><font face="courier new, monospace">   lidar_geom_concrete</font></div><div><font face="courier new, monospace">WHERE</font></div>
<div><font face="courier new, monospace">   st_intersects(the_geom, st_geomfromtext('POLYGON((500 500,500 503,503 503,503 500,500 500))'));</font></div></div><div><br></div><div><div>"Aggregate  (cost=50.30..50.31 rows=1 width=0) (actual time=0.406..0.406 rows=1 loops=1)"</div>
<div>"  ->  Bitmap Heap Scan on lidar_geom_concrete  (cost=4.60..50.29 rows=4 width=0) (actual time=0.362..0.399 rows=16 loops=1)"</div><div>"        Recheck Cond: (the_geom && '010300000001000000050000000000000000407F400000000000407F400000000000407F400000000000707F400000000000707F400000000000707F400000000000707F400000000000407F400000000000407F400000000000407F40'::geometry)"</div>
<div>"        Filter: _st_intersects(the_geom, '010300000001000000050000000000000000407F400000000000407F400000000000407F400000000000707F400000000000707F400000000000707F400000000000707F400000000000407F400000000000407F400000000000407F40'::geometry)"</div>
<div>"        ->  Bitmap Index Scan on idx_lidar_geom_concrete_the_geom  (cost=0.00..4.60 rows=11 width=0) (actual time=0.348..0.348 rows=16 loops=1)"</div><div>"              Index Cond: (the_geom && '010300000001000000050000000000000000407F400000000000407F400000000000407F400000000000707F400000000000707F400000000000707F400000000000707F400000000000407F400000000000407F400000000000407F40'::geometry)"</div>
<div>"Total runtime: 0.485 ms"</div></div><div><br></div><div><br></div><div>It looks like any difference came in the recheck, although the planner expected the functional index (non-concrete geometry) to be faster.</div>
<div><br></div><div>This is based on Postgres 9.1, I have no idea what index-only scans in 9.2 would produce.  Incidentally, playing with FILLFACTOR on the tables and indices didn't help me.</div><div><br></div><div>As another suggestion, I read elsewhere - and some time ago - that it can help to cluster points, perhaps 50 (tbd), into a single record so the bounding box intersection test has much less work to do and you explode etc. the results from there.</div>
<div><br></div><div>Steve</div><div><br></div></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">On Wed, Jan 16, 2013 at 1:49 PM, Bruce Rindahl <</span><a href="mailto:bruce.rindahl@gmail.com" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">bruce.rindahl@gmail.com</a><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">></span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">wrote:</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> I am currently building a large PostGIS database of lidar data and going</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> through several performance tweaks to make 1.5 billion records respond</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> better.  One of the big ones was to convert the z data by multiplying by</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">100</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> and storing it as an integer instead of a double (I know - pretty</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">obvious).</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> The resulting reduction in storage space is significant as is query</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> performance.  The x and y values are stored as a point value in a</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">geometry</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> type which i believe is stored like two double precision values.  Would</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">it</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> be possible to specify a special geometry type using integer values</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">instead</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> of doubles?  You could either add a factor (and a special SRID) or just</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> round the values (possible in my case - are the lidar points really</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">accurate</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> to less than a foot?).  D3.js is doing something very similar to this in</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">its</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> topoJSON format.</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> How much brain damage would this cause?  Just thinking out loud...</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> Bruce</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">></span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> ______________________________</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">_________________</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> postgis-users mailing list</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> </span><a href="mailto:postgis-users@lists.osgeo.org" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">postgis-users@lists.osgeo.org</a><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">> </span><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank" rel="noreferrer" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333015441895px;background-color:rgb(255,255,255)">></span></div>