<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>I'm a little suspicious you don't have ST_MemUnion.  That's been around for a while (since 1.* days) and hasn't been deprecated.  Which version of PostGIS are you using?  And did you upgrade from earlier versions?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Changing the logic to<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal>SELECT st_ashexewkb(st_envelope(st_memunion(st_envelope(…<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Should just work.  In thinking about this, what I really would have liked to do is just use ST_Extent which takes advantage that it's just collapsing boxes and needs to return a box<o:p></o:p></p><p class=MsoNormal>And does do it one at a time similar to ST_MemUnion, but it has a downside that it returns a box and not a geometry with SRID so we'd have to throw a ST_SetSRID in there to convert the box to a geometry with srid, but then we can dispense with the last ST_Envelope.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As far as whether you need an extent constraint, there is no harm in leaving it out in most cases.  Main reason it exists is for tools like QGIS that interrogate the <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>raster_columns table to be able to return a quick extent.  I think for geometry they use ST_EstimateExtent.<o:p></o:p></p><p class=MsoNormal>Even then with those tools, I think no biggie if you have another layer limiting the map extent.  If you have a table that big, using raster overviews is more important.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>One annoying thing about having an extent constraint is you can't add more records without removing the constraint and recomputing.  So if you plan to add more records,<o:p></o:p></p><p class=MsoNormal>I would suggest A) dispense with the constraint  or B) Hand-code the extent constraint to cover the full area you expect your dataset to cover in future.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Question:  How many rows do you have and what is the pixel width height?  <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hope that helps,<o:p></o:p></p><p class=MsoNormal>Regina<o:p></o:p></p><p class=MsoNormal><a href="http://www.postgis.us">http://www.postgis.us</a><o:p></o:p></p><p class=MsoNormal><a href="http://postgis.net">http://postgis.net</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><div><div><p class=MsoNormal style='margin-left:.5in'><br><span style='color:#1F497D'>--- ORIGINAL MESSAGE --</span><br><br>I was importing a very large raster set and after a day it failed with<br>array size exceeds the maximum allowed when setting the extent<br>constraint.<br><br>I redid the import again by just doing the table create and then<br>adding the data and then doing the final bunch of sql statements<br>manually to avoid having the whole thing rollback again.<br><br>I first tried the fix discussed here<br><a href="https://trac.osgeo.org/postgis/ticket/3501" target="_blank">https://trac.osgeo.org/postgis/ticket/3501</a> and implemented here<br><a href="https://trac.osgeo.org/postgis/changeset/15115" target="_blank">https://trac.osgeo.org/postgis/changeset/15115</a> but that failed with<br>the array size error as well.  So I redid the constraints without the<br>extent one.<br><br>I would try ST_MemUnion but unfortunately that one is missing in my<br>installation.  I guess it's because it also handles 3D and the 3D<br>option is not compiled in by default on my platform.<br><br>So, what would a pl/pgsql script to do what MemUnion does, ie<br>accumulate one at a time, look like?<br><br>Also, what issues would not having an extent constrain have?<br><br><o:p></o:p></p></div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div></div></body></html>