I would like to confirm a point with PostgreSQL cursor.
I have to implement a select factory for huge result set query (more than 1Go of small-weight rows). Thus I have learn about cursor and I execute my query the following way:
I create a cursor:
DECLARE HashedCursorName CURSOR FOR SELECT * FROM BigResultSetQuery;
I repetitively fetch small amount of resultset:
FETCH 1000 FROM HashedCursorName;
When resultset is exhausted I close the cursor:
I need to address concurrency, I mean, many users must be able to use the the same query stored in API procedure simultaneously. When a user execute a stored query, he receives a new connection. I first have mangled my cursor name in API because I thought that if all select query are called
StaticCursorName I would have a problem with two user tempting to create the same cursor or reading the same. Everything works as expected.
Then I tried to change the cursor name to a static name, and it still work. I am able to run multiple same query simultaneously. Then I wonder, is cursor bound to connection?, and then does PostgreSQL resolve concurrency by assigning cursor to session?