Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4F0BB1A3BCAC for ; Wed, 29 Feb 2012 06:16:53 -0400 (AST) Received: from mailout.thl.fi ([193.167.195.59]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S2gaZ-00011B-Gp for pgsql-performance@postgresql.org; Wed, 29 Feb 2012 10:16:52 +0000 Received: from mailout (localhost.localdomain [127.0.0.1]) by mailout.thl.fi (8.13.1/8.13.1) with SMTP id q1TAGbYG016766 for ; Wed, 29 Feb 2012 12:16:37 +0200 Received: from 172.24.32.92 (172.24.32.92) by mailout (F-Secure/fsigk_smtp/580/mailout); Wed, 29 Feb 2012 12:16:37 +0200 (EET) X-Virus-Status: clean(F-Secure/fsigk_smtp/580/mailout) Received: from exhub1.stakes.fi (exhub1.stakes.fi [10.10.3.203]) by mail-hub.thl.fi (8.13.8/8.13.8) with ESMTP id q1TAGbY8015985 for ; Wed, 29 Feb 2012 12:16:37 +0200 Received: from [172.24.70.235] (172.24.70.235) by exhub1.stakes.fi (10.10.3.203) with Microsoft SMTP Server id 8.3.83.0; Wed, 29 Feb 2012 12:16:37 +0200 Message-ID: <4F4DFBDF.5050901@thl.fi> Date: Wed, 29 Feb 2012 12:20:15 +0200 From: =?ISO-8859-1?Q?Anssi_K=E4=E4ri=E4inen?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.27) Gecko/20120216 Lightning/1.0b2 Thunderbird/3.1.19 MIME-Version: 1.0 To: "pgsql-performance@postgresql.org" Subject: Large insert and delete batches Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mail-hub.thl.fi id q1TAGbY8015985 X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201202/266 X-Sequence-Number: 46438 Hello all, I am trying to help the Django project by investigating if there should=20 be some default batch size limits for insert and delete queries. This is=20 realted to a couple of tickets which deal with SQLite's inability to=20 deal with more than 1000 parameters in a single query. That backend=20 needs a limit anyways. It might be possible to implement default limits=20 for other backends at the same time if that seems necessary. If I am not mistaken, there are no practical hard limits. So, the=20 question is if performance is expected to collapse at some point. Little can be assumed about the schema or the environment. The inserts=20 and deletes are going to be done in one transaction. Foreign keys are=20 indexed and they are DEFERRABLE INITIALLY DEFERRED by default.=20 PostgreSQL version can be anything from 8.2 on. The queries will be of form: insert into some_table(col1, col2) values (val1, val2), (val3,=20 val4), ...; and delete from some_table where PK in (list_of_pk_values); So, is there some common wisdom about the batch sizes? Or is it better=20 to do the inserts and deletes in just one batch? I think the case for=20 performance problems needs to be strong before default limits are=20 considered for PostgreSQL. The tickets in question are: https://code.djangoproject.com/ticket/17788 and=20 https://code.djangoproject.com/ticket/16426 - Anssi K=E4=E4ri=E4inen