Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dT9Hl-00038U-Fo for pgsql-performance@arkaria.postgresql.org; Thu, 06 Jul 2017 16:05:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dT9Hk-0002u1-AV for pgsql-performance@arkaria.postgresql.org; Thu, 06 Jul 2017 16:05:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dT9Hj-0002tP-7w for pgsql-performance@postgresql.org; Thu, 06 Jul 2017 16:05:43 +0000 Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dT9Hb-0001HT-Fo for pgsql-performance@postgresql.org; Thu, 06 Jul 2017 16:05:42 +0000 Received: by mail-qt0-x22b.google.com with SMTP id b40so6144429qtb.2 for ; Thu, 06 Jul 2017 09:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8eZOt7tlJX/e72sExC3xw3cSjNNKA4yo8N5btlt3Jo4=; b=KdcxVXXoez3+ApSgfHjj4vikGKdjz/CI5jaczrIL73FtDsOlXP3DktlqzTr3aGxzxu ntl4uLvZigojqRAvKDY2jGKAat9RkpsDp2FXQIIpgt6lb5LNI8GMCDQnRdW1XFaXwDyE FTbnpZQLbNEqlb0gslDFTiEe7R1MwkoebdQxlTnMm+0u6zlfDZaFIAMHGUTi2DugdtyX W/AwAMKj0DF4ZawqNIRIoNKLagJ+SXX9bcUI9jH5a7/VQM5poVOP8i/WaOSXvxac8JtQ VDC/fiSYdFrm3Yo6R0UqZVrgQ0xFPrrYOuN3M2O6W/lZkWmKSQADwmMNWC4bAmIQudGi WZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8eZOt7tlJX/e72sExC3xw3cSjNNKA4yo8N5btlt3Jo4=; b=r734qAf9DgvyMB2RTfUrpygHkd9GLvZs9DgTyBlzQxbKKsA7MbRpk1l34jg2Igsih8 GerOhLsnJacBxbnA2TAQleL9opntVrodrEIXunyrw6I9DFpgTGvqDur3HiJ9fMc87n7N vVPdwBussuc5akr/Z85S7eZ3ksgHwh+ABJyjJ9IKEmvn7shrw4pXs1IbyfHE9Dp5nuiG XNzsB1S+Lwti3B6raf22nbaZPhrOsK1yhNwjMA5zw+zElXAa1hVD8bBxBxPnAZPvxLRE HIUOsvXaUpoqm1++K7tZ0W5q7r6LSGAmjiuQ9CeoXRJQ4utSkF7vt210FupNqeDvuS5p MmCQ== X-Gm-Message-State: AKS2vOwwIUco4F7vkbYqiwq+E24/jK9GlgPETvfEqGuvr7c+C76xoEGH J8XKdtWtEzcOMiwYsb08nPFhJD8ilA== X-Received: by 10.200.0.81 with SMTP id i17mr62957932qtg.199.1499357133674; Thu, 06 Jul 2017 09:05:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.177.40 with HTTP; Thu, 6 Jul 2017 09:05:33 -0700 (PDT) In-Reply-To: References: From: Rick Otten Date: Thu, 6 Jul 2017 12:05:33 -0400 Message-ID: Subject: Re: partitioning materialized views To: Shaun Thomas Cc: "pgsql-performa." Content-Type: multipart/alternative; boundary="f403045e736a5820810553a84913" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --f403045e736a5820810553a84913 Content-Type: text/plain; charset="UTF-8" On Thu, Jul 6, 2017 at 11:25 AM, Shaun Thomas wrote: > > I'm curious if I'm overlooking other possible architectures or tools > that might make this simpler to manage. > > One of the issues with materialized views is that they are based on > views... For a concurrent update, it essentially performs a looped > merge, which can be pretty ugly. That's the price you pay to be > non-blocking. For this particular setup, I'd actually recommend using > something like pglogical to just maintain a live copy of the remote > table or wait for Postgres 10's logical replication. Unfortunately the foreign database is Hadoop. (As A Service) > If you _can't_ do > that due to cloud restrictions, you'd actually be better off doing an > atomic swap. > > CREATE MATERIALIZED VIEW y AS ...; > > BEGIN; > ALTER MATERIALIZED VIEW x RENAME TO x_old; > ALTER MATERIALIZED VIEW y RENAME TO x; > DROP MATERIALIZED VIEW x_old; > COMMIT; > > This is an interesting idea. Thanks! I'll ponder that one. > You could still follow your partitioned plan if you don't want to > update all of the data at once. Let's face it, 3-4 hours is still a > ton of data transfer and calculation. > > yup. --f403045e736a5820810553a84913 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

= On Thu, Jul 6, 2017 at 11:25 AM, Shaun Thomas <shaun.thomas@2nd= quadrant.com> wrote:
> I'm curious if I'm overlooking other possible archi= tectures or tools that might make this simpler to manage.

One of the issues with materialized views is that they are based on<= br> views... For a concurrent update, it essentially performs a looped
merge, which can be pretty ugly. That's the price you pay to be
non-blocking. For this particular setup, I'd actually recommend using something like pglogical to just maintain a live copy of the remote
table or wait for Postgres 10's logical replication.
=
Unfortunately the foreign database is Hadoop. =C2=A0(As A Se= rvice)

=C2=A0
= If you _can't_ do
that due to cloud restrictions, you'd actually be better off doing an atomic swap.

CREATE MATERIALIZED VIEW y AS ...;

BEGIN;
ALTER MATERIALIZED VIEW x RENAME TO x_old;
ALTER MATERIALIZED VIEW y RENAME TO x;
DROP MATERIALIZED VIEW x_old;
COMMIT;

This is an interesting idea.=C2=A0 Thanks!=C2=A0 I= 9;ll ponder that one.

=C2=A0
You could still follow your partitioned plan if you don't want to
update all of the data at once. Let's face it, 3-4 hours is still a
ton of data transfer and calculation.


yup.


--f403045e736a5820810553a84913--