Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:50:05+00:00 2026-06-15T16:50:05+00:00

I am writing a program that syncs PostgreSQL and MS SQL server databases (and

  • 0

I am writing a program that syncs PostgreSQL and MS SQL server databases (and adds some changes in this transition). With multi million records, it takes a long time, and loads server pretty bad with select *; it also takes more resources to parse unchanged records and validate them against MS SQL server.

Are there any logs in PostgreSQL that I can parse to find out the changes that took place in the last n-minutes? This would allow me to select only those records that I need to work; improving performance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:50:06+00:00Added an answer on June 15, 2026 at 4:50 pm

    Postgresql, find changes in the last n minutes:

    Postgresql does not automatically store the date or time that rows were added/updated/deleted (it would really slow things down to handle timestamps like this if you didn’t want it to).

    You’ll have to do it yourself: Add a timestamp column to the table. When you insert a row into the table, have it update the timestamp column to the current_timestamp. When you are selecting the row, use a select statement that filters down where timestamp is greater than N minutes ago as follows:

    Get rows where a timestamp is greater than a date:

    SELECT * from yourtable 
    WHERE your_timestamp_field > to_date('05 Dec 2000', 'DD Mon YYYY');
    

    Get rows that have been changed in the last n minutes:

    SELECT * from yourtable 
    WHERE your_timestamp_field > current_timestamp - interval '5 minutes'
    

    Walkthrough example

    drop table foo; 
    CREATE TABLE foo( 
        msg character varying(20), 
        created_date date, 
        edited_date timestamp 
    ); 
    insert into foo values( 'splog adfarm coins', '2015-01-01', current_timestamp);
    insert into foo values( 'execute order 2/3', '2020-03-15', current_timestamp);
    insert into foo values( 'deploy wessels', '2038-03-15', current_timestamp);
     
    select * from foo where created_date < to_date('2020-05-05', 'YYYY-mm-DD'); 
        ┌────────────────────┬──────────────┬────────────────────────────┐ 
        │        msg         │ created_date │        edited_date         │ 
        ├────────────────────┼──────────────┼────────────────────────────┤ 
        │ splog adfarm coins │ 2015-01-01   │ 2020-12-29 11:46:27.968162 │ 
        │ execute order 2/3  │ 2020-03-15   │ 2020-12-29 11:46:27.96918  │ 
        └────────────────────┴──────────────┴────────────────────────────┘ 
     
    select * from foo where edited_date > to_timestamp(
        '2020-12-29 11:42:37.719412', 'YYYY-MM-DD HH24_MI_SS.US'); 
        ┌────────────────────┬──────────────┬────────────────────────────┐ 
        │        msg         │ created_date │        edited_date         │ 
        ├────────────────────┼──────────────┼────────────────────────────┤ 
        │ execute order 2/3  │ 2020-03-15   │ 2020-12-29 11:46:27.96918  │ 
        │ deploy wessels     │ 2038-03-15   │ 2020-12-29 11:46:27.969988 │ 
        └────────────────────┴──────────────┴────────────────────────────┘ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program using RedGate SQL Compare that syncs data between nodes
I'm writing a program that handles DBs and writes any changes into ListView for
HI I'm writing a program that acts as a server and has the ability
I'm writing a program that basically perform server-client relationship. When i run my client
I'm writing a program that loads all the classes from a specified folder. Some
So I am writing the program in xcode that syncs with a database on
I'm new to C but trying some system calls. I'm writing program that iterates
I am writing a program that does some unit conversions from a Brix scale
Im writing a program that saves images from the Internet, but some of the
Im writing a program that should read input via stdin, so I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.