Open javisantana opened 9 years ago
Is there an easy way to estimate export size from a given SQL query?
Another one: this is a problem for formats we are currently streaming. If we can estimate the size before doing the real query it's not a problem.
we could trust in the planer and the stats tables cc @pramsey
Sure can, as long as the stats are gathered. For example, my table of 18000 watersheds…
explain select * from sheds;
Seq Scan on sheds (cost=0.00..8001.81 rows=18481 width=8961) (1 row)
Oh, so 18481 rows at 8961 bytes each?
select 18481 * 8961;
165608241
And final answer?
select sum(st_memsize(geom)) from sheds;
162988032 (1 row)
Not bad! Stats are our friend, the database already knows the answers...
:heart: lovely!
One place this would fail would be if you’re dramatically changing the size of the on-disk object before sending it back to the client, so if you’ve got geom wrapped in ST_Simplify() then the estimate is not going to notice that. However, the estimate will “correctly” (within the bounds of stats knowledge) for things like filters (spatial and non-spatial) and joins.
a 4xx should be raised make configurable per user