<div dir="ltr"><div>Hi PostgAnn,</div><div><br></div><div>Why do you think bitmap heap scan is an issue? Checking the EXPLAIN ANALYSE of the query, looks like the planner uses</div><div>the proper plan to execute the query (the order of magnitude of expected fetched rows and actual fetched after the execution</div><div>is mostly the same). In fact, the index is used: the two phases you see, BitmapHeapScan + BitmapIndexScan, it's because the</div><div>planner builds a bitmap  in the HEAP of the index blocks that are scanned multiple times for query execution, and than the index</div><div>scan is made through this bitmap: it's a way to improve the performance of the index, and it is commonly used by GiST indexes</div><div>for intersects/contains/iscontained spatial operations. It is even expected that the BitmapHeapScan takes most of the execution</div><div>time. <br></div><div><br></div><div>So the execution looks to be the proper one. <br></div><div><br></div><div>Giuseppe.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno ven 22 mag 2020 alle ore 08:11 postgann2020 s <<a href="mailto:postgann2020@gmail.com">postgann2020@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Team,<br><br>Thanks for your support.<br><br>We are using below environment: <br><br><font size="4" color="#ff0000"><b>Application :</b></font><br>=============<br>Programming Language : JAVA<br>Geoserver<br><br>Database Stack:<br>===============<br>PostgreSQL : 9.5.15<br>Postgis<br><br>We have 3 geoserver queries and are getting some performance issues.<br>The index has been created on geom column as well.<br><br><b><font color="#ff0000">The same type of issues found for 3 queries:</font></b><div>=================================<br>1. Bitmap scan is happening.<br>2. All Queries, again index condition checked. </div><div><br></div><div>*******************************************************************************************************************************************************************<br><font size="4" color="#ff0000"><b>Query:</b></font><br><br>explain analyze SELECT "table_name_id","ug_route_sub_type","sw_uid22",encode(ST_AsBinary(ST_Simplify(ST_Force2D("the_geom"), 0.026540849041691673, true)),'base64') as "the_geom" FROM "schema"."table_name" WHERE  ("the_geom" && ST_GeomFromText('POLYGON ((89.91210936248413 -0.0878905905185982, 89.91210936248413 41.04621680978718, 135.0878906061956 41.04621680978718, 135.0878906061956 -0.0878905905185982, 89.91210936248413 -0.0878905905185982))', 4326) AND (("ug_route_sub_type" = 'IP1-IRU-Intercity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'IP1-IRU-Intracity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'IRU-Intracity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'IRU-Intercity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'IP1-Own-Intercity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'IP1-Own-Intracity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Own-Intracity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Own-Intercity' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Own-Intercity-Patch-replacement' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Own-Intracity-Patch-replacement' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Clamping' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'None' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'On kerb' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Other' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'Suspend' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = 'In Duct Chamber' AND "ug_route_sub_type" IS NOT NULL ) OR ("ug_route_sub_type" = '' AND "ug_route_sub_type" IS NOT NULL ) OR "ug_route_sub_type" IS NULL  OR ("sw_uid22" = 'Overhead' AND "sw_uid22" IS NOT NULL  AND "ug_route_sub_type" = 'Own-Intercity' AND "ug_route_sub_type" IS NOT NULL ) OR ("sw_uid22" = 'Overhead' AND "sw_uid22" IS NOT NULL  AND "ug_route_sub_type" = 'Own-Intracity' AND "ug_route_sub_type" IS NOT NULL ) OR ("sw_uid22" = 'Overhead' AND "sw_uid22" IS NOT NULL  AND "ug_route_sub_type" = 'Own-Intercity-Patch-replacement' AND "ug_route_sub_type" IS NOT NULL ) OR ("sw_uid22" = 'Overhead' AND "sw_uid22" IS NOT NULL  AND "ug_route_sub_type" = 'Own-Intracity-Patch-replacement' AND "ug_route_sub_type" IS NOT NULL )));<br>  <br>******************************************************************************</div><div><br></div><div><font size="4"><b><font color="#ff0000">Explain Plan:</font></b>  </font></div><div><br> Bitmap Heap Scan on table_name  (cost=2394.70..139217.49 rows=50676 width=157) (actual time=50.335..535.617 rows=71847 loops=1)<br>   Recheck Cond: (the_geom && '0103000020E61000000100000005000000AA8FF2FF5F7A56403B4CE76BFF7FB6BFAA8FF2FF5F7A5640DC47B36EEA8544408BE7F5FFCFE26040DC47B36EEA8544408BE7F5F<br>FCFE260403B4CE76BFF7FB6BFAA8FF2FF5F7A56403B4CE76BFF7FB6BF'::geometry)<br>   Filter: ((((ug_route_sub_type)::text = 'IP1-IRU-Intercity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'IP1-IRU-Intracity'::text) AN<br>D (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'IRU-Intracity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'IRU-In<br>tercity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'IP1-Own-Intercity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub<br>_type)::text = 'IP1-Own-Intracity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'Own-Intracity'::text) AND (ug_route_sub_type IS NOT NUL<br>L)) OR (((ug_route_sub_type)::text = 'Own-Intercity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'Own-Intercity-Patch-replacement'::tex<br>t) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'Own-Intracity-Patch-replacement'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_su<br>b_type)::text = 'Clamping'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'None'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_rout<br>e_sub_type)::text = 'On kerb'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'Other'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_<br>route_sub_type)::text = 'Suspend'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((ug_route_sub_type)::text = 'In Duct Chamber'::text) AND (ug_route_sub_type IS NOT NU<br>LL)) OR (((ug_route_sub_type)::text = ''::text) AND (ug_route_sub_type IS NOT NULL)) OR (ug_route_sub_type IS NULL) OR (((sw_uid22)::text = 'Overhead'::text) AND (sw_ui<br>d22 IS NOT NULL) AND ((ug_route_sub_type)::text = 'Own-Intercity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((sw_uid22)::text = 'Overhead'::text) AND (sw_uid22 IS<br> NOT NULL) AND ((ug_route_sub_type)::text = 'Own-Intracity'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((sw_uid22)::text = 'Overhead'::text) AND (sw_uid22 IS NOT N<br>ULL) AND ((ug_route_sub_type)::text = 'Own-Intercity-Patch-replacement'::text) AND (ug_route_sub_type IS NOT NULL)) OR (((sw_uid22)::text = 'Overhead'::text) AND (sw_ui<br>d22 IS NOT NULL) AND ((ug_route_sub_type)::text = 'Own-Intracity-Patch-replacement'::text) AND (ug_route_sub_type IS NOT NULL)))<br>   Heap Blocks: exact=45957<br>   ->  Bitmap Index Scan on table_name_the_geom_geo_idx  (cost=0.00..2382.03 rows=64216 width=0) (actual time=30.147..30.147 rows=71847 loops=1)<br>         Index Cond: (the_geom && '0103000020E61000000100000005000000AA8FF2FF5F7A56403B4CE76BFF7FB6BFAA8FF2FF5F7A5640DC47B36EEA8544408BE7F5FFCFE26040DC47B36EEA8544408BE<br>7F5FFCFE260403B4CE76BFF7FB6BFAA8FF2FF5F7A56403B4CE76BFF7FB6BF'::geometry)<br> Planning time: 0.906 ms<br><font size="4" color="#ff0000"><b> Execution time: 541.423 ms</b></font><br>(8 rows)<br><br>Could you please suggest a better way to execute the query.<br><br>Thanks for your support.<br><br>Regards,<br>PostgAnn.<br></div></div>
_______________________________________________<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/mailman/listinfo/postgis-users</a></blockquote></div>