Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zf9IE-0005qx-0z for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Sep 2015 16:22:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zf9ID-00043u-34 for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Sep 2015 16:22:45 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zf3Gz-0007kz-J8 for pgsql-bugs@postgresql.org; Thu, 24 Sep 2015 09:57:05 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Zf3Gx-0000f1-An for pgsql-bugs@postgresql.org; Thu, 24 Sep 2015 09:57:04 +0000 MIME-Version: 1.0 Subject: BUG #13635: Interlocks at selection with array_agg To: pgsql-bugs@postgresql.org From: pawel.samysev@gmail.com Date: Thu, 24 Sep 2015 09:56:26 +0000 Message-ID: <20150924095626.2596.10390@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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: 13635 Logged by: pawel Email address: pawel.samysev@gmail.com PostgreSQL version: 9.4.4 Operating system: Debian 7 Description: My company develops mailing server. We introduce new server and copy database to it. It has 24 processor server. Every tables has millions records. After copy we start update tables.We run 72 queries at parallel at different part of table. And we periodical see locks with drammatical fail productivity. But query shouldn`t create any interlocks. Query: ``` UPDATE phone p SET mailing_id = ( SELECT array_agg(mailing_id) FROM message m WHERE m.phone_id = p.phone_id ) WHERE p.phone_id BETWEEN :min AND :max ``` Table schemas: ``` -- Table: phone -- DROP TABLE phone; CREATE TABLE phone ( phone_id bigserial NOT NULL, -- Primary key "number" character varying(15), -- Number date_modified timestamp with time zone DEFAULT now(), region_id integer, -- ID region of number last_visit interval, mailing_id integer[], client_db_id integer[], CONSTRAINT phone_pkey PRIMARY KEY (phone_id), CONSTRAINT phone_number_key UNIQUE (number) ) WITH ( OIDS=FALSE ); ALTER TABLE phone OWNER TO "postgres"; GRANT ALL ON TABLE phone TO "postgres"; -- Index: phone_client_db_id_idx -- DROP INDEX phone_client_db_id_idx; CREATE INDEX phone_client_db_id_idx ON phone USING gin (client_db_id); -- Index: phone_mailing_id_idx -- DROP INDEX phone_mailing_id_idx; CREATE INDEX phone_mailing_id_idx ON phone USING gin (mailing_id); -- Index: phone_number_idx -- DROP INDEX phone_number_idx; CREATE INDEX phone_number_idx ON phone USING btree (number COLLATE pg_catalog."default"); -- Index: phone_region_id_idx -- DROP INDEX phone_region_id_idx; CREATE INDEX phone_region_id_idx ON phone USING btree (region_id); -- Table: message -- DROP TABLE message; CREATE TABLE message ( message_id integer NOT NULL DEFAULT nextval('message_message_id_seq'::regclass), -- Primary key mailing_id integer, phone_id integer, message_status integer, date_added timestamp without time zone, date_modified timestamp without time zone, CONSTRAINT message_pkey PRIMARY KEY (message_id) ) WITH ( OIDS=FALSE ); ALTER TABLE message OWNER TO "postgres"; -- Index: message_date_modified_idx -- DROP INDEX message_date_modified_idx; CREATE INDEX message_date_modified_idx ON message USING btree (date_modified); -- Index: message_mailing_id_idx -- DROP INDEX message_mailing_id_idx; CREATE INDEX message_mailing_id_idx ON message USING btree (mailing_id); -- Index: message_message_id_idx -- DROP INDEX message_message_id_idx; CREATE INDEX message_message_id_idx ON message USING btree (message_id); -- Index: message_message_status_idx -- DROP INDEX message_message_status_idx; CREATE INDEX message_message_status_idx ON message USING btree (message_status); -- Index: message_phone_id_idx -- DROP INDEX message_phone_id_idx; CREATE INDEX message_phone_id_idx ON message USING btree (phone_id); ``` -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs