<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>The query takes over a minute the first time, then about 3 seconds on subsequent queries. Some on-the-fly index must need to be constructed the first time, and it is cached for a period afterwards (though the initial performance reoccurs after some idle period, like an hour or so).<br><br>Yes, in this case it only returns 9 rows, because my bounding box is small. <br><br></div>I am getting 4x4=16 tiles - the requests are done in parallel so it's not a straight 3x16 seconds calculation.<br><br></div>Ah yes, duplicate indexes! Thanks for catching that! Would that incur a performance hit on database reads?<br><br></div>Thanks,<br></div>-Andy<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 1, 2017 at 10:28 AM, Andy Colson <span dir="ltr"><<a href="mailto:andy@squeakycode.net" target="_blank">andy@squeakycode.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 03/31/2017 11:38 AM, Andrew Gaydos wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
<br>
explain analyze SELECT "streamflow",encode(ST_AsBinar<wbr>y(ST_Simplify(ST_Force2D("wkb_<wbr>geometry"), 1.0357088025898521E-4)),'base6<wbr>4') as "wkb_geometry" FROM "public"."flow_view" WHERE  ("timeid" = 81388 AND "timeid" IS NOT NULL  AND "wkb_geometry" && ST_GeomFromText('POLYGON ((-115.13723373413087 41.01267720039345, -115.13723373413087 41.04660520510985, -115.09225845336915 41.04660520510985, -115.09225845336915 41.01267720039345, -115.13723373413087 41.01267720039345))', 4269) AND (("streamflow" > -1.0E-4 AND "streamflow" IS NOT NULL  AND "streamflow" < 5.0) OR ("streamflow" > 4.9999 AND "streamflow" IS NOT NULL  AND "streamflow" < 10.0) OR ("streamflow" > 9.9999 AND "streamflow" IS NOT NULL  AND "streamflow" < 15.0) OR ("streamflow" > 14.9999 AND "streamflow" IS NOT NULL  AND "streamflow" < 20.0) OR ("streamflow" > 19.9999 AND "streamflow" IS NOT NULL  AND "streamflow" < 25.0) OR ("streamflow" > 24.9999 AND "streamflow" IS NOT NULL  AND "streamflow" < 30.0) OR ("streamflow" > 29.9999 AND "streamflow" IS NOT NULL  AND "streamflow" < 100000.0)));<br>
<br>
<br>
     QUERY PLAN<br>
------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>--<br>
 Nested Loop  (cost=0.70..163.24 rows=11 width=465) (actual time=0.101..0.200 rows=9 loops=1)<br>
<br>
Thanks for any insight!<br>
<br>
-Andy<br>
</blockquote>
<br>
<br>
Does that query really only return 9 rows?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Planning time: 3041.998 ms<br>
 Execution time: 1.192 ms<br>
</blockquote>
<br>
So this query, by itself only takes 3 seconds.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
about 10 seconds for all the tiles to be served<br>
</blockquote>
How many tiles does it request?  Math (10/3 = ~3) would tell us 3 tiles, but that would be odd.  I'd think 4 or 8 tiles.<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    "flow_times_pkey" PRIMARY KEY, btree (id)<br>
    "flow_times_id_idx" btree (id)<br>
</blockquote>
<br>
You have two indexes on the same field on flow_times.<br>
<br>
-Andy<br>
______________________________<wbr>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/postgis-users</a></blockquote></div><br></div>