How to determine how much disk-space postgresql 9.1 requires as temp_space to run a query? Given a query q to execute. Is there a way to determine how much disk-space postgresql will (or used) as temporary_space in order to execute it (during its execution) ? 

I'm under Ubuntu 12.0.4 with postgresql 9.1
Knowing how much will be used is hard.  How much has been used, you there are logging options for that.

set log_temp_files=0;
set client_min_messages TO log;
select count(distinct x) from generate_series(1,10000000) x;



  LOG:  temporary file: path "base/pgsql_tmp/pgsql_tmp25126.2", size 120127488.
  
  LOG:  temporary file: path "base/pgsql_tmp/pgsql_tmp25126.1", size 140000000