Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9m0h-0001Rv-LE for pgsql-general@arkaria.postgresql.org; Wed, 10 Feb 2021 09:42:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l9m0g-00007h-K0 for pgsql-general@arkaria.postgresql.org; Wed, 10 Feb 2021 09:42:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9m0g-00007Z-9v for pgsql-general@lists.postgresql.org; Wed, 10 Feb 2021 09:42:10 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l9m0c-0006yF-DR for pgsql-general@lists.postgresql.org; Wed, 10 Feb 2021 09:42:09 +0000 Received: by mail-ej1-x635.google.com with SMTP id hs11so2969666ejc.1 for ; Wed, 10 Feb 2021 01:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=eYPTQEe5qySqdN28ic7Ar2I3XPbs4Ojd0BaUsF6nSqM=; b=PvkxG6qH7ikmVZwEw4cJVITxHNFj6H5+dzgkC/PjZaHXTL6lR63tXwAcpwWvqbFCPP FlSRW+P1cTUh6CF8hZUvKOF/94p7tmvGCOQqDEBT4CX+q/6BqIerUWdxbOw8HTsYQW6i b30lOte4NOhJJyDbGFB4mmMdTArwf+HalVegHFpvUvktb31zgu1T5AxU7oi8HqgtYIAg I8fw1Z3Qy1GbF1gXoPUpikQOomv4Z+x+AOvikZx45XlrJCCeFLOh9UL3jjmKynCxdq74 PkhvGAW14NRRbGDar0WgaRlT7ZOyL6ij3pGxdWd4S0xZvBOhk66d6PqDur8UtnBPruMs huIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=eYPTQEe5qySqdN28ic7Ar2I3XPbs4Ojd0BaUsF6nSqM=; b=AtpTLcIFCYplsPZydhn5fZ0WCFMj9sJ5p3HfAsp+GQu2eaNzkZdMbFcOwaVlqQR88i u0O5Wy3Q/1rC6pAGtMOxX22jkNBN8RHtlVygB6ZiceCANWSsg6BDJb0t37Nj1f1uXTEx eMqIMxn1CW8I0fFzRi1uNcqLGBMfD9enRmpkzXAo8k1ydvtNNVzHL6ru6sbhFxQB0KwC lZCa1ywZiWBl3amNDDOxIMYzbqKD9oER/xUmpFhmXn5bPvdpt/ElOUlyEWHMuKk1eTui 5/av81XDy1z2IN02pK1HFJdgvfenjvrdnGxqYOIYdCX8W+8/y1OqSorBYfbMgAMwnVTZ NPkA== X-Gm-Message-State: AOAM5320OAjRdAbTfIbR5oL9BLNys5f/c0iUum7+1unrr92x/Cgo/zKS Y4FHET2UBRG+3w9sXL4NEHpgVGz1c6eWww== X-Google-Smtp-Source: ABdhPJyg9G6HX0MpuSZ76XeT/ZEZSRxZMR/gr3HFIq8eDXoa08D4fYYWbIAP9Xs6jgq0CsJIalVpIQ== X-Received: by 2002:a17:906:40f:: with SMTP id d15mr2137689eja.522.1612950124239; Wed, 10 Feb 2021 01:42:04 -0800 (PST) Received: from cens-MacBook-Pro.local (BSN-95-228-180.static.siol.net. [193.95.228.180]) by smtp.gmail.com with ESMTPSA id v26sm576524edw.23.2021.02.10.01.42.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Feb 2021 01:42:03 -0800 (PST) Subject: Re: Regarding Postgres - Insertion Time Getting Increased As Data Volume is getting increased To: pgsql-general@lists.postgresql.org References: From: cen Message-ID: <7afc2339-9fe5-de4c-80ea-c8b0b9a28a3a@gmail.com> Date: Wed, 10 Feb 2021 10:42:02 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: sl List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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.