[postgis-devel] ST_Union for Raster

dustymugs dustymugs at gmail.com
Thu Jan 19 15:55:29 PST 2012


On 01/19/2012 03:41 PM, Nathaniel Clay wrote:
> Hi all,
>
> I was reading the code for Union for raster. I came away with the
> impression that St_Union operating on a raster copies cell by cell is this
> correct?  The is this leading to the high execution time that I am seeing?
>

Yes and no.

Yes to ST_Union going over each pixel of each raster as each pixel has 
to be evaluated based upon whatever pixel evaluation expression/function 
ST_Union (and the underlying ST_MapAlgebra function) is using.

No because ST_Union is written in plpgsql thereby incurring a 
significant penalty for each raster being passed to ST_Union.  For each 
raster passed into ST_Union, 2 deserializations (one for the unioned 
raster and the other for the raster being added to the unioned raster) 
and 1 serialization (for the unioned raster) is taking place.  To make 
things worse, the time required for serializing and deserializing the 
unioned raster may increase with each ST_Union call if the raster is 
growing.

As the SQL function prototype is final for 2.0, it is planned to replace 
the plpgsql ST_Union function with a C ST_Union function that should 
dramatically improve performance.  Hopefully, this can be done for 2.0.1.

-bborie



More information about the postgis-devel mailing list