user24370809
user24370809

Reputation: 1

Getting unique range from SQL sequence for concurrent requests

Using Postgres I've created a sequence

CREATE SEQUENCE seq INCREMENT BY 1000;

I need to get from it boundaries of a unique range of 1000, which works with multiple concurrent requests.

Using the code shown here seems to return the needed result (for example; (1, 1001))

SELECT last_value, nextval('seq') FROM seq;

Is it going to work the right way with multiple concurrent requests?

Upvotes: 0

Views: 46

Answers (0)

Related Questions