From: Niels Jespersen <NJN@dst.dk>
To: prachi surangalikar <surangalikarprachi100@gmail.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: SV: Insertion time is very high for inserting data in postgres
Date: Wed, 10 Feb 2021 11:10:41 +0000
Message-ID: <280e6bd026024e389657ae15ba169e90@dst.dk> (raw)
In-Reply-To: <CAFeB3PVKPcS77-cwJ-oy9=0=jKdsQ2rCzQnXsKxhKnbqQDHMJg@mail.gmail.com>
References: <CAFeB3PVKPcS77-cwJ-oy9=0=jKdsQ2rCzQnXsKxhKnbqQDHMJg@mail.gmail.com>
>Fra: prachi surangalikar <surangalikarprachi100@gmail.com>
>
>Hello Team,
>Greetings!
>
>We are using Postgres 12.2.1 for fetching per minute data for about 25 machines but running parallely via a single thread in python.
>But suddenly the insertion time has increased to a very high level, about 30 second for one machine.
>We are in so much problem as the data fetching is becoming slow.
>
>if anyone could help us to solve this problem it would be of great help to us.
Get your data into a Text.IO memory structure and then use copy https://www.psycopg.org/docs/usage.html#using-copy-to-and-copy-from
This is THE way of high-performant inserts using Postgres.
Regards Niels Jespersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: NJN@dst.dk, surangalikarprachi100@gmail.com
Subject: Re: Insertion time is very high for inserting data in postgres
In-Reply-To: <280e6bd026024e389657ae15ba169e90@dst.dk>
References: <CAFeB3PVKPcS77-cwJ-oy9=0=jKdsQ2rCzQnXsKxhKnbqQDHMJg@mail.gmail.com> <280e6bd026024e389657ae15ba169e90@dst.dk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox