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 1lQvO7-0002Fp-06 for pgsql-novice@arkaria.postgresql.org; Mon, 29 Mar 2021 17:09:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lQvO5-0003XP-Sy for pgsql-novice@arkaria.postgresql.org; Mon, 29 Mar 2021 17:09:13 +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 1lQvO5-0003XI-K9 for pgsql-novice@lists.postgresql.org; Mon, 29 Mar 2021 17:09:13 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lQvO1-00037o-IA for pgsql-novice@postgresql.org; Mon, 29 Mar 2021 17:09:12 +0000 Received: by mail-ed1-x536.google.com with SMTP id h10so15009608edt.13 for ; Mon, 29 Mar 2021 10:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=XhgtY+Kd8kdPPJ7ztxtDe/3llbfmcL6+r0ZDTuaniqk=; b=Si/RRhr7ADxG0i0/2OD0XNUEtQHaHos/WwecOZVxXNqNXZCTC5vHeOMoM0sksrsihx n+H3AIdPrbnFo3lbUFNnWkwN9uD6q1TaUp44lLqSS2foOJ1MEhyQO4jkuZQwPjmrvJO1 UzoVwfX+o83OyxuBc0HvcRPFxWWjNKiEce9X91SWUpi/2oCARmtLm9Uz1QT7ekkoSz5N Ie40cnfAR/5iJsN3YvydP2tB7T/niOjwKLNabkXqTbzBQnsGUs7iSVkAwcGyYB7istHw ZD+ilvEGy65z9dR6L3QTRKLyFXqnLmOHiiSl/x/PR08BJ8tuSwdW61ecpwHdcSdbUwyp 9XSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=XhgtY+Kd8kdPPJ7ztxtDe/3llbfmcL6+r0ZDTuaniqk=; b=Az0Nc6wgEPEd6hEt/ZwffbAdXoQfET8VZRZLcqEtlUce9NbmuiJ4CsIzu93PLqMn2f YOYBl3hcWKeWcwe5ThRMWqr30WFL4uwhJrraRH2vh6Bojg+RJXtAqzljp95vT/ah+RD/ 8a7Rjbupp1/rswKPz9q9YKM0/THoieMneZ2daeps/guk3+QYb5nHGUBuxwrkbMa4jAzi gjxlC3w9w/JIDKJZZ9oq5aEZkGSu91CUvqybOYSUQsqUGElLO+aobrz+Jh9ZtyUOIV7V 7AW9OIdysbbfXzB/LWn8xbtxZRHZcS1XvXvKkIVuMfBFf1drJ3TLlZ3moVUjwkCDmgUR MeHw== X-Gm-Message-State: AOAM5318GemW5yI4KalZKIXd1/EKrXgRk5YUYYdi47/DDQ2T/AMonbHB +mV2FjhvhhCqLa+LADdDJoXJMg== X-Google-Smtp-Source: ABdhPJxwnS4rx1aVMJ1nMoepme/iQUWYgRwBq3lOeb55Tu4593nbitWhSTzk0cKDToaW+1UGkObNEw== X-Received: by 2002:aa7:d484:: with SMTP id b4mr29578933edr.63.1617037746692; Mon, 29 Mar 2021 10:09:06 -0700 (PDT) Received: from localhost.localdomain (217-149-168-72.nat.highway.telekom.at. [217.149.168.72]) by smtp.gmail.com with ESMTPSA id bc16sm5017672edb.17.2021.03.29.10.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 10:09:06 -0700 (PDT) Message-ID: Subject: Re: shared buffers From: Laurenz Albe To: Greg Rychlewski , pgsql-novice@postgresql.org Date: Mon, 29 Mar 2021 19:09:02 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) 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 Mon, 2021-03-29 at 11:27 -0400, Greg Rychlewski wrote: > Will every page touched during a table or index scan, even if it's > not going to be used in the final result, be loaded into shared buffers? > > i.e. if you need to evaluate a filter condition, will it load that page > into shared buffers and then evaluate it from there? Even if a value does not appear in a query result, the page containing it has to be read, if the value is used for calculating the query result. All pages read are loaded into shared buffers. So yes, they will be loaded. Note that there is an optimization for big sequential scans: if the table scanned is bigger than a quarter of shared buffers, PostgreSQL will use a small ring buffer to read the table. This prevents a large sequential scan from blowing out your cache, since it uses the same buffers to scan the whole table. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com