Re: Incorrect number of rows inserted into partitioned table - Mailing list pgsql-bugs

From David Rowley
Subject Re: Incorrect number of rows inserted into partitioned table
Date
Msg-id CAApHDvrY3UJN5xfZ6pACx3zdctXw7jCUaP9GdvfRpUW5vxUENQ@mail.gmail.com
Whole thread Raw
In response to Incorrect number of rows inserted into partitioned table  (Роман Осипов <osipovromanvladimirovich@gmail.com>)
List pgsql-bugs
On Tue, 11 Apr 2023 at 08:50, Роман Осипов
<osipovromanvladimirovich@gmail.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



pgsql-bugs by date:

Previous
From: Роман Осипов
Date:
Subject: Incorrect number of rows inserted into partitioned table
Next
From: Tomas Vondra
Date:
Subject: Re: Incorrect number of rows inserted into partitioned table