SPI Concurrency Precautions? - Mailing list pgsql-hackers

From Tom Mercha
Subject SPI Concurrency Precautions?
Date
Msg-id DB7PR05MB508322D30B743D57A9E77771F4160@DB7PR05MB5083.eurprd05.prod.outlook.com
Whole thread Raw
Responses Re: SPI Concurrency Precautions? Problems with Parallel Execution ofMultiple CREATE TABLE statements
List pgsql-hackers
Dear Hackers

I've been working on an extension and using SPI to execute some queries. 
I am in a situation where I have the option to issue multiple queries 
concurrently, ideally under same snapshot and transaction. In short, I 
am achieving this by creating multiple dynamic background workers, each 
one of them executing a query at the same time using 
SPI_execute(sql_string, ...). To be more precise, sometimes I am also 
opting to issue a 'CREATE TABLE AS <sql_query>' command, an SPI utility 
command.

I was however wondering whether I can indeed achieve concurrency in this 
way. My initial results are not showing much difference compared to a 
not concurrent implementation. If there would be a large lock somewhere 
in SPI implementation obviously this can be counterintuitive. What would 
be the precautions I would need to consider when working with SPI in 
this manner?

Thanks,
Tom



pgsql-hackers by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: Unicode normalization SQL functions
Next
From: Alvaro Herrera
Date:
Subject: pg_trigger.tgparentid