From: cen <cen.is.imba@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Regarding Postgres - Insertion Time Getting Increased As Data Volume is getting increased
Date: Wed, 10 Feb 2021 10:42:02 +0100
Message-ID: <7afc2339-9fe5-de4c-80ea-c8b0b9a28a3a@gmail.com> (raw)
In-Reply-To: <CADH9T5OtrQD3cr17j8miFzEX=brueOH2qC_=TP8oZAROG+sd2g@mail.gmail.com>
References: <CADH9T5OtrQD3cr17j8miFzEX=brueOH2qC_=TP8oZAROG+sd2g@mail.gmail.com>
On 10. 02. 21 09:14, Rajnish Vishwakarma wrote:
> Hi Postgres Team,
>
> The below are the scenarios which we are dealing with.
>
> 1) There are 20 Tables - On an average each having 150 columns.
>
> 2) There are 20 Threads Handled by Thread Pool Executor ( here we are
> using Python's - psycopg2 module / library to fetch the data .)
>
> 3) I am using the below statement to insert the data using Python -
> psycopg2 module - using the exceute(...) command as .
>
> sql_stmt = "INSERT INTO " + name_Table + final_col_string + "VALUES" +
> str(tuple(array_of_curly_values))
> print('Sql statement', sql_stmt)col_cursor_db = db_conn.cursor()
> v = col_cursor_db.execute(sql_stmt);
>
> But earlier the same 22 threads were running and the insertion time
> was gradually increased from 1 second to 30-35 seconds.
>
> Requesting and urging the postgres general support team to help me out
> on this.
>
> How can i increase the INSERTION speed to minimize the insertion time
> taken by each thread in the THREAD POOL.
>
> Or there any different python libraries other than psycopg2 ?
>
> Is there any different functions in python psycopg2 ?
>
> Or what performance tuning has to be done to increaser the insertion
> speed ?
>
>
Is a single insert taking 30 seconds or do you have such a large number
of inserts that your thread pool can't handle it and you are waiting for
a free connection?
For single insert, one reason for slowness at large databases could be
indexes which need to be updated for each insert. For the latter, you
should increase the thread pool size.
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: cen.is.imba@gmail.com
Subject: Re: Regarding Postgres - Insertion Time Getting Increased As Data Volume is getting increased
In-Reply-To: <7afc2339-9fe5-de4c-80ea-c8b0b9a28a3a@gmail.com>
References: <CADH9T5OtrQD3cr17j8miFzEX=brueOH2qC_=TP8oZAROG+sd2g@mail.gmail.com> <7afc2339-9fe5-de4c-80ea-c8b0b9a28a3a@gmail.com>
* 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