[postgis-users] Extent on multiple tables

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Fri Oct 21 03:42:52 PDT 2005


Hi Lars/strk,

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net 
> [mailto:postgis-users-bounces at postgis.refractions.net] On 
> Behalf Of strk at refractions.net
> Sent: 21 October 2005 11:22
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] Extent on multiple tables
> 
> 
> You might try:
> 
> 	select extent(g) from (
> 		select the_geom from table1
> 		union all
> 		select the_geom from table2
> 	) as foo;

Isn't there an extent() missing from each of the individual tables?
Otherwise you have to load all the geometries from all the tables into
memory before you calculate the overall extent, rather than working on a per
table basis. I would suggest something like:

select extent(g) from (
	select extent(the_geom) AS g FROM table1
	union all
	select extent(the_geom) AS g FROM table2
) as foo;

Or if you can live with slightly inaccurate extents then the super-fast
estimated_extent() version would look like:

select extent(g) from (
	select estimated_extent(the_geom) AS g FROM table1
	union all
	select estimated_extent(the_geom) AS g FROM table2
) as foo;


Kind regards,

Mark.

------------------------
WebBased Ltd
17 Research Way
Plymouth
PL6 8BT

T: +44 (0)1752 797131
F: +44 (0)1752 791023

http://www.webbased.co.uk   
http://www.infomapper.com 
http://www.swtc.co.uk  

This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify the sender. You should not copy it or
use it for any purpose nor disclose or distribute its contents to any other
person.





More information about the postgis-users mailing list