Reputation: 361
I'm trying to access data from a table that was created or updated data 30 seconds from the current time. Does anyone have any good idea of how to do this efficiently? I'm using node.js and pg package in npm. I want to grab the newly created/updated data to sync with elasticsearch.
Upvotes: 2
Views: 1543
Reputation:
The rows that were created exactly 30 seconds ago:
select *
from the_table
where createdat = current_timestamp - interval '30' second
The rows that were created between 30 seconds ago and now:
select *
from the_table
where createdat >= current_timestamp - interval '30' second
Upvotes: 3