<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rich</title>
    <description>The latest articles on DEV Community by Rich (@d0nkeybob).</description>
    <link>https://dev.to/d0nkeybob</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F119475%2F4440ddb9-b434-4274-bd04-820e3d4e5c87.jpg</url>
      <title>DEV Community: Rich</title>
      <link>https://dev.to/d0nkeybob</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/d0nkeybob"/>
    <language>en</language>
    <item>
      <title>Postgres table partitioning with Rails</title>
      <dc:creator>Rich</dc:creator>
      <pubDate>Fri, 03 Jan 2020 19:50:21 +0000</pubDate>
      <link>https://dev.to/d0nkeybob/postgres-table-partitioning-with-rails-439j</link>
      <guid>https://dev.to/d0nkeybob/postgres-table-partitioning-with-rails-439j</guid>
      <description>&lt;p&gt;Hi all, Our system currently uses Postgresql 9.6 with Rails but has been having table performance problems. We decided to add table partitioning and I created the triggers to do that. My problem is that &lt;code&gt;CREATE&lt;/code&gt; works perfectly, but &lt;code&gt;UPDATE&lt;/code&gt; gives me constraint errors. Has anyone had good luck in implementing this? I would also note that I added a &lt;code&gt;DELETE&lt;/code&gt; trigger for removing the row from parent after insert, but that gives me problems in tests because it can't find the row. Any help would be greatly appreciated. Thanks&lt;/p&gt;

&lt;p&gt;example of error&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PG::ForeignKeyViolation: ERROR:  insert or update on table "table2" violates foreign key constraint "fk_rails_647be12f23"
         DETAIL:  Key (id)=(7867) is not present in table "table1".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm assuming I'm missing something that's right in front of my face but I can't seem to find the right posts/articles to jog that.&lt;/p&gt;

&lt;p&gt;To answer some questions on the problem:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;have you tried testing the partitions without Rails?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I have through psql statements. updates don't work. I'm assuming that I would need a seperate process for moving the record, but I haven't found clear solutions to help.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do the various CRUD operations work?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inserts do&lt;/p&gt;

&lt;p&gt;&lt;em&gt;how are the partitions defined?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Through a check on an id and by month&lt;/p&gt;

&lt;p&gt;&lt;em&gt;what are you using in Rails to support partitions?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Just function triggers in Postgres. no gem usage&lt;/p&gt;

</description>
      <category>help</category>
      <category>postgres</category>
      <category>rails</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
