-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Postgres trigger #9218
base: main
Are you sure you want to change the base?
Postgres trigger #9218
Conversation
# Conflicts: # mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
Outdated
Show resolved
Hide resolved
mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
Outdated
Show resolved
Hide resolved
mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
Outdated
Show resolved
Hide resolved
mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
Outdated
Show resolved
Hide resolved
|
||
conn.add_notify_handler(process_event) | ||
# trigger getting updates | ||
conn.execute("SELECT 1").fetchone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spam db with query each 0.5s looks badly. Let put here comment with reminder to rewrite it to generator when psycopg 3.2.2 will be released (they added timeout arg there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed timeout to 1s. 'select 1' is not heavy operation. added line on psycopg example of this approach
in future we could modify trigger to process batch operation: all rows changed since last call (1s) will be processed as one dataframe.
# Conflicts: # mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
call add_notify_handler only once
Description
Added
subscribe
method to postgres handler.How it works:
Limitations:
Example
Demo
https://www.loom.com/share/8b27d9c467e6471e89ab22121daa7b85
Fixes #issue_number
Type of change
Verification Process
To ensure the changes are working as expected:
Additional Media:
Checklist: