Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFYTz-003OTe-D5 for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2024 12:14:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sFYTx-00BNgT-QW for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2024 12:14:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFYTx-00BNfm-F3 for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2024 12:14:10 +0000 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sFYTv-0009gE-Ap for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2024 12:14:08 +0000 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-2506bd2e0ecso855630fac.3 for ; Fri, 07 Jun 2024 05:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717762446; x=1718367246; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=3p3RLyd0Rth2mROcE9jjh1iJFuysZab3fTybxhsdZ0E=; b=KFT2hZINZ0JDgv5ep4cUrNgV5vwylbP1iqGn7yZG93TG1cEiRCAKH5tV/w/FjzBd8r abP+gfyRpdzB5PlvC31yrPGTRUOLA/vA6zJ6mHVuabEtcGwzrtxdkFPTRBYCisbxX6La RaCBGhIfcM5clNP5tHjlqxLqkUxfQXzuz1upWW5fOBe8nAy2m6siDF4YbcPoUtxh/fUU j7VCVmLtwJ/6ACysvFHbH6191HxlCyHekh92KCe9cwn18oK1J48wBDrGbQ9XqXOjELAD Hp5hNoKKROHgrx2xcv/hrCnuGEhb2CmK4Ao2Zuumy2tAbPY9U3VJ4RwBpuYiERHPPsJ/ Gl9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717762446; x=1718367246; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3p3RLyd0Rth2mROcE9jjh1iJFuysZab3fTybxhsdZ0E=; b=sPaB0OTSU6NCe9Ys52QZz2qYCJfBd3+P5kq53gZHWogYV2UKv8YkBeQ+R3uik1+NB7 riCFQ+qYt0nVTfyaLWqlSBNVq6oTkFBt45FtiljqtREWsoavMBYoCm6+N2IKWeCFzNfG tEMEP8H+3cQu/OT+t9f15r8S6bTLzP5fcgLMiEBLgzd5ExdeTAcw86nimdnD4Im1lkEb 2XwwR/ZLmboIssdZsYLsNTwphYzWKHO+P6m8++hNHRmCBgKjdJnOXbZIJwezXJLS6/Q7 u39uuMaUupswA0TrNEGlvhI+rsSue7BtISlYd4WpGQuXTZgfSPdkFDCRwLAC+6zd65JC 1vqA== X-Gm-Message-State: AOJu0YwGAxIjLlA1UrUUYOAe4l8RT2JTdTbzRcZCS7QzSMWYTWfmlB8Z 73fdsziEO0+mxp3UNcKKBBGwmphh4XP65oNPuW0b/7kVaKV65pja9SoY6qQzGr/6cL0k2Us3AaE 0NFpVcksrkp3W3qI2psRE2w35Q6TMQS29 X-Google-Smtp-Source: AGHT+IFvaRgZ7JoXUqWLsiezQbm4O0k357HRPjdAKWRbcRqRUYt2DSNATXyv06F7zGKKjsfl5b48D2t010s+UBhbROM= X-Received: by 2002:a05:6870:a54c:b0:24f:d57f:86af with SMTP id 586e51a60fabf-25464c27fd2mr2486583fac.19.1717762446301; Fri, 07 Jun 2024 05:14:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Fri, 7 Jun 2024 08:13:55 -0400 Message-ID: Subject: Re: Poor performance after restoring database from snapshot on AWS RDS To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000006ba438061a4bbc52" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006ba438061a4bbc52 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 7, 2024 at 4:36=E2=80=AFAM Sam Kidman wrote: > > This is due to the way that RDS restores snapshots. > > Thanks, I never would have guessed. Would vacuum analyze be sufficient > to defeat the lazy loading or would we need to do something more > specific to our application? (for example. select(*) on some commonly > used tables) > https://www.postgresql.org/docs/14/pgprewarm.html pg_prewarm is probably what you want. Don't know if RDS Postgresql supports it or not, though. > > I think vacuum full would certainly defeat the lazy loading since it > would copy all of the table data, but that may take a very long time > to run. I think vacuum analyze only scans a subset of rows but I might > be wrong about that. > > Best, Sam > > On Wed, Jun 5, 2024 at 10:09=E2=80=AFPM Jeremy Smith > wrote: > > > > On Wed, Jun 5, 2024 at 4:23=E2=80=AFAM Sam Kidman wrot= e: > > > > > We get very poor performance in the staging environment after this > > > restore takes place - after some usage it seems to get better perhaps > > > because of caching. > > > > > > > This is due to the way that RDS restores snapshots. > > > > From the docs ( > https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RestoreFromSn= apshot.html > ): > > > > You can use the restored DB instance as soon as its status is > > available. The DB instance continues to load data in the background. > > This is known as lazy loading. > > > > If you access data that hasn't been loaded yet, the DB instance > > immediately downloads the requested data from Amazon S3, and then > > continues loading the rest of the data in the background. > > > > > > > > -Jeremy > > > --0000000000006ba438061a4bbc52 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Jun 7, 2024 at 4:36=E2=80=AFAM Sa= m Kidman <sam@fresho.com> wrote= :
> This is due to the way that RDS restores snapshots.

Thanks, I never would have guessed. Would vacuum analyze be sufficient
to defeat the lazy loading or would we need to do something more
specific to our application? (for example. select(*) on some commonly
used tables)


pg_prewarm is probably what you= want.=C2=A0 Don't know if RDS Postgresql supports it or not, though.
=C2=A0

I think vacuum full would certainly defeat the lazy loading since it
would copy all of the table data, but that may take a very long time
to run. I think vacuum analyze only scans a subset of rows but I might
be wrong about that.

Best, Sam

On Wed, Jun 5, 2024 at 10:09=E2=80=AFPM Jeremy Smith <jeremy@musicsmith.net> wrot= e:
>
> On Wed, Jun 5, 2024 at 4:23=E2=80=AFAM Sam Kidman <sam@fresho.com> wrote:
>
> > We get very poor performance in the staging environment after thi= s
> > restore takes place - after some usage it seems to get better per= haps
> > because of caching.
> >
>
> This is due to the way that RDS restores snapshots.
>
> From the docs (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RestoreFrom= Snapshot.html):
>
> You can use the restored DB instance as soon as its status is
> available. The DB instance continues to load data in the background. > This is known as lazy loading.
>
> If you access data that hasn't been loaded yet, the DB instance > immediately downloads the requested data from Amazon S3, and then
> continues loading the rest of the data in the background.
>
>
>
>=C2=A0 =C2=A0-Jeremy


--0000000000006ba438061a4bbc52--