Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oic1f-0006ck-1W for pgsql-general@arkaria.postgresql.org; Wed, 12 Oct 2022 13:43:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oic1d-0006F0-Qv for pgsql-general@arkaria.postgresql.org; Wed, 12 Oct 2022 13:43:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oic1d-0006Ei-Gi for pgsql-general@lists.postgresql.org; Wed, 12 Oct 2022 13:43:57 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oic1a-00033f-M2 for pgsql-general@postgresql.org; Wed, 12 Oct 2022 13:43:56 +0000 Received: by mail-ej1-x631.google.com with SMTP id k2so38116159ejr.2 for ; Wed, 12 Oct 2022 06:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=dzHVdAwlD94nozEIrjvBW55x2gseChS0lVaukEe5sgo=; b=pGDb1K+XN+6leFtGOmsM7SWKKrCc2rqiaaXq9mcDi05/US5bwQ270Pfxb/RD1tx0ZI 8FdEXUNU3yi9FPDORdFtUf8hMW44ClDUzHFu2v8E3tvMs09UrlUOqNb5NBe1AU0wxTAm trG0XG9nSZz445vbSkJx+cgrALKuZ26PpCZ1WrwZttQ7JPfAAjFpeNW6VC02XsDyy4lM w35XGd7lO+XozTXA1S3Vy2OrFeGnzcg6RKQQf66OkiGuhqUqh6F7qvXVoYwJbdrLGmsm fpRVvmweL8FndaJnclaKd6kea/oBLrzaJnAQFWOQIr8rD4iDpSn9lUG89DDrUKJyyGYP Xy8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dzHVdAwlD94nozEIrjvBW55x2gseChS0lVaukEe5sgo=; b=QfdfoU6EOEN87z2J3oObnSGCX24Pmm3z7NrnJDSkwxF9dmfnfNyyysoq0JyjEtwXGm tAPqnYXA/hN6MuHaYm5hjh0deD1btWZoLZW/Zb+40Y7EWoYsny0/r6DSCRM+kPhwj2ZY 35h/YDajAYzZwpM8Qpz29SWrYFveIDVghRBo1PD+LJitYZLUgkAA5lvycsMvKOdb4NMf rLCjL9v0ARbcQoM/mzzt2e/eZDTVNthGJQ65ra+MDTD4stvL2eMYSSqDCI0Q2M0Sto0p QyZKnxS27cXpelKFgAx3KfPqPEGEWrY0SrdEgs0yfWle5Fch8QNILc7epSo3WF6aIPsZ 4yEg== X-Gm-Message-State: ACrzQf1MOWMBdmE6K3Vm8lCBPHB6CLJVjvXYDLRFnJfVoQ9WPmXOEy+T 7bqf0p57lVjnQyx4/XN7kstqYg== X-Google-Smtp-Source: AMsMyM57e+QrHnxAIRAx3fvhEnhTHIur8+4gqB8+BJyTPxHEvBz3TjuhSC768XvpJDbhQrsoorybGQ== X-Received: by 2002:a17:907:6d8f:b0:78d:9b5e:1a0f with SMTP id sb15-20020a1709076d8f00b0078d9b5e1a0fmr17576880ejc.23.1665582233192; Wed, 12 Oct 2022 06:43:53 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:4e2c:199f:95ac:ae91:db7e]) by smtp.gmail.com with ESMTPSA id z11-20020aa7d40b000000b00458d50b4a24sm11044108edq.96.2022.10.12.06.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 06:43:52 -0700 (PDT) Message-ID: Subject: Re: Weird planner issue on a standby From: Laurenz Albe To: Guillaume Lelarge , Alvaro Herrera Cc: Tom Lane , PostgreSQL General Date: Wed, 12 Oct 2022 15:43:51 +0200 In-Reply-To: References: <418848.1665505048@sss.pgh.pa.us> <20221011162736.cd2h5ajdbhtwdc4l@alvherre.pgsql> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2022-10-12 at 10:51 +0200, Guillaume Lelarge wrote: > Just finished my phone call. So, they definitely have their performance back. All they did was a VACUUM on two tables. > > If I understand correctly, during "normal" operations, some information is stored on the primary > and sent to standbys. For some reason, only the primary take them into account, standbys ignore them. > That would explain why, when we promoted a standby without doing anything else, it had much better > performance. VACUUM fixes the issue on a standby, probably by storing this information in a different > way. After VACUUM, standbys stop ignoring this information, which helps get the performance back. > > That sounds like a plausible explanation. I still have questions if you don't mind: > * what is this information? > * where is it stored? my guess would be indexes > * why is it ignored on standbys and used on primary? That sounds indeed like killed (LP_DEAD) index tuples on the primary. Peter says they are ignored on the standby anyway, so on the standby PostgreSQL went through a lot of index entries pointing to dead table tuples, and it took a long time to find the maximal entry in the table, which is done by the optimizer. VACUUM removed those dead tuples and their associated index entries on both primary and standby. Yours, Laurenz Albe