Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j7M6p-0003mg-LT for pgsql-general@arkaria.postgresql.org; Thu, 27 Feb 2020 16:34:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j7M6o-0006Wa-EE for pgsql-general@arkaria.postgresql.org; Thu, 27 Feb 2020 16:33:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j7M6o-0006WT-05 for pgsql-general@lists.postgresql.org; Thu, 27 Feb 2020 16:33:58 +0000 Received: from mx3.wp.pl ([212.77.101.9]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j7M6l-0006BK-5G for pgsql-general@lists.postgresql.org; Thu, 27 Feb 2020 16:33:57 +0000 Received: (wp-smtpd smtp.wp.pl 861 invoked from network); 27 Feb 2020 17:33:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1582821233; bh=dTzn8oCzrIiWD4Rc8m6yPelNZUrXD3GKif5JpqlIapY=; h=Subject:To:From; b=gBoT00uR8tfAb4Kwrk7CXafxMiWJE6Zh4YNcSIQqSD/ES+eIJyR4yHA0ysSu4W4AT AIaZq3e3WvUQzD3XDgcc58w/MkXNXVampZkKk6Mx71jwgQCMvTVloYMY0wrK9YU2bA 8IzaNxm+YaqsFgd7mYVzI5QgL/RnWB9/smGpnAqk= Received: from 78-11-36-98.cmr.net.pl (HELO [192.168.1.226]) (ipluta@wp.pl@[78.11.36.98]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 27 Feb 2020 17:33:53 +0100 Subject: Re: Need to find the no. of connections for a database To: "sivapostgres@yahoo.com" , "pgsql-generallists.postgresql.org" References: <1393516227.2562442.1582789296867.ref@mail.yahoo.com> <1393516227.2562442.1582789296867@mail.yahoo.com> <1654972450.2631031.1582803351218@mail.yahoo.com> <72f62e47-689a-351a-a711-6cfb7312d282@wp.pl> <1401820409.2680701.1582810637855@mail.yahoo.com> <561727835.2707508.1582813582038@mail.yahoo.com> From: "Ireneusz Pluta/wp.pl" Message-ID: Date: Thu, 27 Feb 2020 17:33:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <561727835.2707508.1582813582038@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: pl X-WP-MailID: 7065e8cd417f33a81ca4e9183672b629 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000009 [UKMU] List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk W dniu 2020-02-27 o 15:26, sivapostgres@yahoo.com pisze: > Need to lock around 10 tables.  Let me try with pg_advisory_lock(). I am not sure why you mention table locks at this point. Just in case: with advisory locks you lock an "application flow", not database objects. > > > On Thursday, 27 February, 2020, 07:39:13 pm IST, Ireneusz Pluta/wp.pl wrote: > > > W dniu 2020-02-27 o 14:37, sivapostgres@yahoo.com pisze: > > Hello, > > > > I'm saying isolation will not work out to my requirement.   The steps. > > > > 1.  On completion of all entries by all,  say for a day. > > 2.  Lock, so that no one enters any other data. > > 3.  Create a report from the entered data. > > 4.  Create / Modify required entries from the values arrived in the report. [ long process ] > > 5.  Once completed, commit all data. > > 6.  Unlock, so that other users can enter data again.  Data entered will be for another date. > > Data cannot [should] not entered for the processed date. > > > so wouldn't pg_advisory_lock() in step 2, and pg_advisory_unlock() in step 6, make the process work > in the way you expect? > > https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS > > > > > > > On Thursday, 27 February, 2020, 06:29:00 pm IST, Ireneusz Pluta/wp.pl > wrote: > > > > > > W dniu 2020-02-27 o 12:35, sivapostgres@yahoo.com > > pisze: > > > > > > I need to prevent other users from entering any transaction till I finish taking reports from my > > > application.  All users will be using the same application, from which this report is supposed to > > > be printed. > > > > > > > maybe advisory lock is what you need? > > > > https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS > > > > > > > > > >