SELECT st_band(rast, 1), st_width(rast), st_height(rast),
st_bandpixeltype(rast, 1), st_bandnodatavalue(rast, 1),
st_scalex(rast), st_scaley(rast), st_upperleftx(rast),
st_upperlefty(rast) FROM public.elevation WHERE st_intersects(rast,
st_polygonfromtext('POLYGON((-94.00010416666670210
67.50010416666670210, -93.00010416666670210 67.50010416666670210,
-93.00010416666670210 67.00010416666670210, -94.00010416666670210
67.00010416666670210, -94.00010416666670210 67.50010416666670210))',
4269))
There's a GIST index created over rast column:
CREATE INDEX elevation_rast_gist
ON elevation
USING gist
(st_convexhull(rast) );
This is the 'explain analyze' output
Seq Scan on elevation (cost=0.00..6.30 rows=1 width=32) (actual
time=2039.622..2614.787 rows=2 loops=1)
Filter: (((rast)::geometry &&
'0103000020AD1000000100000005000000511BE8B4018057C0511BE8B401E05040511BE8B4014057C0511BE8B401E05040511BE8B4014057C0511BE8B401C05040511BE8B4018057C0511BE8B401C05040511BE8B4018057C0511BE8B401E05040'::geometry)
AND _st_intersects('0103000020AD1000000100000005000000511BE8B4018057C0511BE8B401E05040511BE8B4014057C0511BE8B401E05040511BE8B4014057C0511BE8B401C05040511BE8B4018057C0511BE8B401C05040511BE8B4018057C0511BE8B401E05040'::geometry,
rast, NULL::integer))
Total runtime: 2615.145 ms
The coordinates used in intersection are not important. The point is I want to fetch all raster rows that intersect a given window. So:
- Is there any other additional index I should create?
- Is there any other way to write the query to make it faster?
Many thanks in advance, and best regards,