Tempo tables used on queries running at the same time throwing already exists error

150 views Asked by At

I'm running multiple queries (in diffent sessions) which use the following code, some times in paralell, and I was getting errors saying the temp table already existed. I was under the impression the temp tables would just be using some sort of random name in the background processing so these don't interfiere with each other:

select country_id, product_category_id, sum(units) as total_units
into temp totals
from schema.table
group by country_id, product_category_id;

I'm getting this:

Query failed: ERROR: relation "totals" already exists.

Postgres version is 9.4 and this only happens when using pgbouncer port

Am I doing something wrong? Should I use create temp table instead?

Thanks,

1

There are 1 answers

0
Matias On

It was the pgbouncer set up, we had the pool_mode as transaction, once we changed it to session it worked OK