Re: Incorrect number of rows inserted into partitioned table

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Роман Осипов <osipovromanvladimirovich(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Incorrect number of rows inserted into partitioned table
Date: 2023-04-10 21:36:16
Message-ID: CAApHDvrY3UJN5xfZ6pACx3zdctXw7jCUaP9GdvfRpUW5vxUENQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 11 Apr 2023 at 08:50, Роман Осипов
<osipovromanvladimirovich(at)gmail(dot)com> wrote:
> When reloading data from a simple table into a partitioned (through inheritance) using a query like: insert into [new_partition_table] select * from [old_table] limit xxxxxxx;
>
> There is an insertion not of the amount specified in limit,, but a little more or less than it.

It would be good to see what your output actually is. I don't
currently see a way for the number of rows inserted to be *more* than
the LIMIT. If it's less, then that'll be because of the rule you have
defined to insert into another table instead.

With your example SQLs, you'll probably find that the reported number
of inserted rows matches: select count(*) from ONLY book_inherit_test;

Also, you might want to look at declarative partitioning [1] and use
that instead.

David

[1] https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITIONING-DECLARATIVE

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomas Vondra 2023-04-10 21:39:07 Re: Incorrect number of rows inserted into partitioned table
Previous Message Роман Осипов 2023-04-10 18:42:28 Incorrect number of rows inserted into partitioned table