Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make FETCH NEXT FROM cur a blocking call #18107

Closed
lmatz opened this issue Aug 19, 2024 · 2 comments
Closed

make FETCH NEXT FROM cur a blocking call #18107

lmatz opened this issue Aug 19, 2024 · 2 comments

Comments

@lmatz
Copy link
Contributor

lmatz commented Aug 19, 2024

Is your feature request related to a problem? Please describe.

https://risingwave-labs.slack.com/archives/C0358PVT2AX/p1723721407947399:

Hi folks. Is there anyway to make FETCH NEXT FROM cur block until the data arrives?
The current design is not good for event-driven architecture:

while True:
  # Fetch the next row from the cursor
  cur.execute("FETCH NEXT FROM cur;")
  row = cur.fetchone()

  if row is None:
    # Sleep for 1 second if no row is fetched
    time.sleep(1)
    continue

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

@npadbidri
Copy link

Agree with @lmatz . Sans this ability to be notified, we are forced to poll Rising Wave. We query Rising Wave every Clock Second to check on new data arrival. For those vast majority instances, when there is no data, we continue to inundate Rising Wave every clock second, with our request to return data. Having Pub/Sub support would basically act like Long Polling; this would also lead to lesser resource consumption on the Rising Wave Server.

@hzxa21
Copy link
Collaborator

hzxa21 commented Oct 17, 2024

Done in #18675. It will be included in release 2.1.

  • Non-blocking: FETCH ...
  • Blocking: FETCH ... with (timeout = 'xxx')

@hzxa21 hzxa21 closed this as completed Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants