Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5xM6-00067T-A2 for pgsql-performance@arkaria.postgresql.org; Thu, 14 Feb 2013 11:51:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5xM5-0008Mg-5c for pgsql-performance@arkaria.postgresql.org; Thu, 14 Feb 2013 11:51:57 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5xM4-0008MZ-1Z for pgsql-performance@postgresql.org; Thu, 14 Feb 2013 11:51:56 +0000 Received: from mail-ve0-f169.google.com ([209.85.128.169]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5xM2-0000yH-0R for pgsql-performance@postgresql.org; Thu, 14 Feb 2013 11:51:55 +0000 Received: by mail-ve0-f169.google.com with SMTP id 15so2020160vea.0 for ; Thu, 14 Feb 2013 03:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:references:mime-version:in-reply-to:content-type :content-transfer-encoding:message-id:cc:x-mailer:from:subject:date :to; bh=v8OhA0wssWid9pJDFALGjv7s1tOiVBFJwJ7CnJbqt6Q=; b=v1Zx5MgePZJjn4yzRRtGu6XGoE+DtzRNZSGZHxYzNy1HTHHKgecQlpqrXV5FzYBX4/ oSDP1kOM5McURc1wnqRyxINjUJ9FCFarb0PQfiXeBlSeTzaNxB9M070IKz/AO3oBRJwO ijp1tckSSYGrp3pVzE2R75zzOOuwrVTC8+ztBHtGxlzM/vC96EtiouzwWNF+0p/dj0FZ tqBECuLLY/e5gF938foPEPtpgMfPUHXYE3NzYT5aHwxImXCtE598/y7tQp0d95Sa6qul j5fx2PVGYAAyf7Z1Z7RyTBcRljOuB00KD85FwKeuE+3s/RKZPVRtHjpngKxNIBCZfJTi ZxnA== X-Received: by 10.52.24.229 with SMTP id x5mr23921816vdf.84.1360842713075; Thu, 14 Feb 2013 03:51:53 -0800 (PST) Received: from [192.168.0.101] (cpe-107-015-250-076.nc.res.rr.com. [107.15.250.76]) by mx.google.com with ESMTPS id kn18sm74677968veb.5.2013.02.14.03.51.51 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Feb 2013 03:51:52 -0800 (PST) References: <511CBC55.9080804@lignano.it> Mime-Version: 1.0 (1.0) In-Reply-To: <511CBC55.9080804@lignano.it> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: Cc: "pgsql-performance@postgresql.org" X-Mailer: iPhone Mail (10B142) From: nik9000@gmail.com Subject: Re: 700K Inserts in transaction Date: Thu, 14 Feb 2013 06:51:49 -0500 To: Asmir Mustafic X-Pg-Spam-Score: -2.3 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Are the duplicates evenly distributed? You might have started on a big chu= nk of dupes. I'd go about this by loading my new data in a new table, removing the dupes= , then inserting all the new data into the old table. That way you have mor= e granular information about the process. And you can do the initial load w= ith copy if you need it. And you can remove the dupes outside of a transact= ion.=20 Nik Sent from my iPhone On Feb 14, 2013, at 5:28 AM, Asmir Mustafic wrote: > Hi everybody! > I'm new in mailing list, and i have a little question. >=20 >=20 > The tables are: > postalcodes (place_id, code), PK(place_id, code) 600K of rws > places (id, name), PK(id), INDEX(name) 3M of rows >=20 > I've to insert another 600k of rows into postalcodes table, in a single t= ransaction, omitting duplicates. >=20 > The insert query is a prepared statement like this: >=20 > INSERT INTO postalcodes (place_id, code) > SELECT places.id, :code > FROM places > LEFT JOIN postalcodes (postalcodes.place_id =3D places.id and postalcodes= .code =3D :code) > WHERE places.name =3D :name AND postalcodes.place_id IS NULL >=20 > Inserting rows works well (3000 queries per second), but when i reach 30K= of executed statements, the insert rate slows down to 500/1000 queries per= second). >=20 > Doing a commit every 20K of inserts, the insert rate remain 3000 queries = per second. >=20 > There is a limit of inserts in a transaction? >=20 >=20 >=20 >=20 >=20 > --=20 > Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-performance --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance