Re: [GENERAL] Partitioning and ORM tools

2016-03-29 Thread Brian Fehrle
Here is a working example of trigger based partitioning with a view and 'do instead' that works with ORM tools using the affected rows return (example attached). The key things that make it work are: 1. RETURN NEW; (in the function after inserting into the partition) 2. INSTEAD OF INSERT (in th

Re: [GENERAL] Partitioning and ORM tools

2016-03-24 Thread CS DBA
On 03/23/2016 02:48 AM, Chris Travers wrote: On Wed, Mar 23, 2016 at 9:39 AM, Chris Travers mailto:chris.trav...@gmail.com>> wrote: Use a view with a DO INSTEAD trigger. That will allow you to return the tuple properly. On Tue, Mar 22, 2016 at 7:40 PM, CS DBA mailto:cs_...

Re: [GENERAL] Partitioning and ORM tools

2016-03-23 Thread Chris Travers
On Wed, Mar 23, 2016 at 9:39 AM, Chris Travers wrote: > Use a view with a DO INSTEAD trigger. That will allow you to return the > tuple properly. > > On Tue, Mar 22, 2016 at 7:40 PM, CS DBA > wrote: > >> Hi All; >> >> we setup partitioning for a large table but had to back off because the >> r

Re: [GENERAL] Partitioning and ORM tools

2016-03-23 Thread Chris Travers
Use a view with a DO INSTEAD trigger. That will allow you to return the tuple properly. On Tue, Mar 22, 2016 at 7:40 PM, CS DBA wrote: > Hi All; > > we setup partitioning for a large table but had to back off because the > return status (i.e: "INSERT 0 1") returns "INSERT 0 0" when inserting i

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread John R Pierce
On 3/22/2016 2:20 PM, CS DBA wrote: I would think the ORM (as yet undefined) would want to think in terms of the parent table and not know about the physical schema details. Can the client not be written to check only for errors vs checking for non-zero inserts? That was our first suggesti

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Manuel Kniep
> So the ORM is parsing the INSERT return value, correct? > > Would something like this(borrowing from docs example) freak it out?: > > CREATE OR REPLACE FUNCTION measurement_insert_trigger() > RETURNS TRIGGER AS $$ > DECLARE >_ct int; > BEGIN >INSERT INTO measurement_y2016m03 VALUES (NEW

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Manuel Kniep
> So the ORM is parsing the INSERT return value, correct? > > Would something like this(borrowing from docs example) freak it out?: > > CREATE OR REPLACE FUNCTION measurement_insert_trigger() > RETURNS TRIGGER AS $$ > DECLARE >_ct int; > BEGIN >INSERT INTO measurement_y2016m03 VALUES (NEW

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Adrian Klaver
On 03/22/2016 02:20 PM, CS DBA wrote: On 03/22/2016 03:18 PM, Rob Sargent wrote: On 03/22/2016 03:00 PM, Joshua D. Drake wrote: On 03/22/2016 01:50 PM, CS DBA wrote: Understood, was just wondering if there is a way to cause the child table insert results to be returned to the ORM/Applicat

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Melvin Davidson
On Tue, Mar 22, 2016 at 5:20 PM, CS DBA wrote: > > > On 03/22/2016 03:18 PM, Rob Sargent wrote: > >> >> >> On 03/22/2016 03:00 PM, Joshua D. Drake wrote: >> >>> On 03/22/2016 01:50 PM, CS DBA wrote: >>> >>> Understood, was just wondering if there is a way to cause the child table insert resu

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread CS DBA
On 03/22/2016 03:18 PM, Rob Sargent wrote: On 03/22/2016 03:00 PM, Joshua D. Drake wrote: On 03/22/2016 01:50 PM, CS DBA wrote: Understood, was just wondering if there is a way to cause the child table insert results to be returned to the ORM/Application instead of the master/base table in

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Rob Sargent
On 03/22/2016 03:00 PM, Joshua D. Drake wrote: On 03/22/2016 01:50 PM, CS DBA wrote: Understood, was just wondering if there is a way to cause the child table insert results to be returned to the ORM/Application instead of the master/base table insert Insert into the child table directly ba

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Joshua D. Drake
On 03/22/2016 01:50 PM, CS DBA wrote: Understood, was just wondering if there is a way to cause the child table insert results to be returned to the ORM/Application instead of the master/base table insert Insert into the child table directly based on the partition rules. JD -- Command Promp

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread CS DBA
On 03/22/2016 02:43 PM, Joshua D. Drake wrote: On 03/22/2016 01:35 PM, CS DBA wrote: On 03/22/2016 02:23 PM, Joshua D. Drake wrote: On 03/22/2016 11:40 AM, CS DBA wrote: Hi All; we setup partitioning for a large table but had to back off because the return status (i.e: "INSERT 0 1") ret

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Joshua D. Drake
On 03/22/2016 01:35 PM, CS DBA wrote: On 03/22/2016 02:23 PM, Joshua D. Drake wrote: On 03/22/2016 11:40 AM, CS DBA wrote: Hi All; we setup partitioning for a large table but had to back off because the return status (i.e: "INSERT 0 1") returns "INSERT 0 0" when inserting into the partitione

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread CS DBA
On 03/22/2016 02:23 PM, Joshua D. Drake wrote: On 03/22/2016 11:40 AM, CS DBA wrote: Hi All; we setup partitioning for a large table but had to back off because the return status (i.e: "INSERT 0 1") returns "INSERT 0 0" when inserting into the partitioned table which causes the ORM tool to as

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Melvin Davidson
On Tue, Mar 22, 2016 at 4:23 PM, Joshua D. Drake wrote: > On 03/22/2016 11:40 AM, CS DBA wrote: > >> Hi All; >> >> we setup partitioning for a large table but had to back off because the >> return status (i.e: "INSERT 0 1") returns "INSERT 0 0" when inserting >> into the partitioned table which c

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Joshua D. Drake
On 03/22/2016 11:40 AM, CS DBA wrote: Hi All; we setup partitioning for a large table but had to back off because the return status (i.e: "INSERT 0 1") returns "INSERT 0 0" when inserting into the partitioned table which causes the ORM tool to assume the insert inserted 0 rows. Is there a stand

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread CS DBA
On 03/22/2016 01:10 PM, Rob Sargent wrote: On 03/22/2016 12:55 PM, Melvin Davidson wrote: Your problem seems strange as it has never been previously reported for anyone else that has _successfully_ set up partioning. Perhaps is you provide just a little bit more detail we might be able to h

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Kris Deugau
Melvin Davidson wrote: > Your problem seems strange as it has never been previously reported for > anyone else that has _successfully_ set up partioning. At least as of when I asked a very similar question (http://www.postgresql.org/message-id/flat/547f7e88.7080...@vianet.ca#547f7e88.7080...@viane

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Rob Sargent
On 03/22/2016 12:55 PM, Melvin Davidson wrote: Your problem seems strange as it has never been previously reported for anyone else that has _successfully_ set up partioning. Perhaps is you provide just a little bit more detail we might be able to help you. Useful and needed information would

Re: [GENERAL] Partitioning and ORM tools

2016-03-22 Thread Melvin Davidson
Your problem seems strange as it has never been previously reported for anyone else that has _successfully_ set up partioning. Perhaps is you provide just a little bit more detail we might be able to help you. Useful and needed information would be: 1. Version of PostgreSQL 2. Operating System 3. T

[GENERAL] Partitioning and ORM tools

2016-03-22 Thread CS DBA
Hi All; we setup partitioning for a large table but had to back off because the return status (i.e: "INSERT 0 1") returns "INSERT 0 0" when inserting into the partitioned table which causes the ORM tool to assume the insert inserted 0 rows. Is there a standard / best practices work around fo