Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOpF3-0004dj-OO for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Sep 2013 13:34:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VOpF3-0001UQ-7r for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Sep 2013 13:34:57 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOpF2-0001UK-J7 for pgsql-bugs@postgresql.org; Wed, 25 Sep 2013 13:34:56 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOpEz-00077A-GK for pgsql-bugs@postgresql.org; Wed, 25 Sep 2013 13:34:55 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOpEy-00087J-KM for pgsql-bugs@postgresql.org; Wed, 25 Sep 2013 13:34:53 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VOpEt-0003nc-4J for pgsql-bugs@postgresql.org; Wed, 25 Sep 2013 13:34:47 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8470: 9.3 locking/subtransaction performance regression To: pgsql-bugs@postgresql.org From: os@ohmu.fi Message-Id: Date: Wed, 25 Sep 2013 13:34:47 +0000 X-Pg-Spam-Score: -3.9 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8470 Logged by: Oskari Saarenmaa Email address: os@ohmu.fi PostgreSQL version: 9.3.0 Operating system: Linux Description: The following code performs a lot slower on PostgreSQL 9.3.0 than on PostgreSQL 9.2.4: DROP TABLE IF EXISTS tmp; CREATE TABLE tmp (id BIGSERIAL, vals BIGINT[]); DO $$ DECLARE r_id BIGINT; n BIGINT; BEGIN FOR n IN 1..1000 LOOP BEGIN SELECT id INTO r_id FROM tmp WHERE array_length(vals, 1) < 100 LIMIT 1 FOR UPDATE NOWAIT; EXCEPTION WHEN lock_not_available THEN r_id := NULL; END; IF r_id IS NULL THEN INSERT INTO tmp (vals) VALUES (ARRAY[n]::BIGINT[]); ELSE UPDATE tmp SET vals = array_append(vals, n::BIGINT) WHERE id = r_id; END IF; END LOOP; END; $$; PostgreSQL 9.3.0: Time: 7278.910 ms PostgreSQL 9.2.4: Time: 128.008 ms Removing the BEGIN/EXCEPTION/END block and just doing a 'SELECT FOR UPDATE' for a suitable row is significantly slower in 9.3.0 (314.765 ms vs 118.894 ms on 9.2.4). A 'SELECT' without a FOR UPDATE and BEGIN/EXCEPTION/END has the same performance on 9.2.4 and 9.3.0. I'm running 9.2.4 and 9.3.0 packages from apt.postgresql.org on a Debian Squeeze host. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs