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 1oBcEE-0003ti-FI for pgsql-admin@arkaria.postgresql.org; Wed, 13 Jul 2022 13:16:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oBcED-00075r-Ad for pgsql-admin@arkaria.postgresql.org; Wed, 13 Jul 2022 13:16:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oBcEC-00075i-UC for pgsql-admin@lists.postgresql.org; Wed, 13 Jul 2022 13:16:33 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oBcEA-0004r3-NE for pgsql-admin@lists.postgresql.org; Wed, 13 Jul 2022 13:16:32 +0000 Received: by mail-oi1-x236.google.com with SMTP id x185so4731788oig.1 for ; Wed, 13 Jul 2022 06:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=HypcB6mlGjTZO8ScCCi1KfmE0FoMA2bDLCD40H6sYok=; b=CwBM8HDl1OHawKl/TcLsNl9XSRrMvDIS9mOKPNOO7L1fFNKO+tUYm1KVtZLYUrNbhs 9GLj4CX+LloQM+6Mglanpjem5F6pDZsDpMvlInuKeJ0kaVEQLuJ6sGEFN0DF6VUv5xjv HPcvBP7Jqff2uNZPZ5aeRWsxcGNbvS7xcOV6KIHNx3FRiILtSSYdH3OiGla9wE4wZymK McJnbbbnz5gknT6pUfE/YGwGlZ0M+IVuPjBkyjDbnY2kmwzKlBwJo4ZyNR6nwHKO3DHs pShRMx0ALFH1CGHVoyK3tIZr7imBZtUtk9BFiYunMv9umqFnTsFEziClkils9Rcdxtvi BnIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=HypcB6mlGjTZO8ScCCi1KfmE0FoMA2bDLCD40H6sYok=; b=xLMouQzGlSs3W53+GSOCyZzvFQYtKKuEqMjizHarw304DxV9lvAy64nFSgOuL9Wfi6 6axE0YN18GtKPYEL+tq820SHm36DzETJZPljVv2Ys+iYS+97mH365Bsk5clpKNk/p26U S0ag318vqSGTfzPW7PwKjhNu/J6LL0UdFJsxgZv1KvyNe7fCSR2xL4jPw4i6Yjr4Qa+/ aQYbRNHXYl/6SiHz2ixHlPDuEHCqv6ExlcLjOJLXDs2/yapcCtSjWPeUgCXUwBf+y4Xc rd0OgeWRWVKUR+u6/VLaf9DshcES7xKYoN9xCenIdarhDUTWVjo2ElaL4yp2H3HRHsIm 9p0w== X-Gm-Message-State: AJIora8HxwabyhIx81A2Sc1crrX648yIz3ZzAVhf0qzYqtTFCHVzSNgI 0r7HK0wPBtQF0rCdAtS3ezbKuuf9aXw= X-Google-Smtp-Source: AGRyM1txHjKmCUpx6XkyFe5SOcfmbYYAeAoSP2VjSZ9RRAY2ooc/WAvJtkEaPa3hWuX6t+QIZJ65WQ== X-Received: by 2002:a05:6808:201c:b0:335:8112:dd85 with SMTP id q28-20020a056808201c00b003358112dd85mr1696372oiw.150.1657718188677; Wed, 13 Jul 2022 06:16:28 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id x6-20020a4ab906000000b00425678b9c4bsm4814737ooo.0.2022.07.13.06.16.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 06:16:28 -0700 (PDT) Message-ID: <3dc59390-b2ab-4ccb-3e3f-cc7a1c095829@gmail.com> Date: Wed, 13 Jul 2022 08:16:27 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [EXT] Improve "select count(*)" query - takes more than 30 mins for some large tables Content-Language: en-US To: pgsql-admin@lists.postgresql.org References: <1B1927BA-F7DE-40E8-8F67-BCC001CD4C6B@gmail.com> <1eb233ff-90f0-529b-f0cc-fa982f668a8f@gmail.com> <1221536526.20277.1657636277921@email.ionos.com> <1037158693.49441.1657650345834@email.ionos.com> <05fa08bf8b4e1023eb879bcab0f83d428e4f7a43.camel@cybertec.at> <647F11EE-BBDA-46C1-8591-96B2C1DCE66C@elevated-dev.com> From: Ron In-Reply-To: <647F11EE-BBDA-46C1-8591-96B2C1DCE66C@elevated-dev.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/12/22 21:28, Scott Ribe wrote: >> On Jul 12, 2022, at 8:12 PM, MichaelDBA wrote: >> >> Oh really? Even if it did an INDEX ONLY SCAN, it would still be slower because it still has to access the heap in a random I/O kinda way (like I said-->"The heap always gets accessed for select counts") because visibility info is only found in the HEAP not the index. > This changed in 9.something. There is now a visibility map, which can, for data that hasn't changed recently, How recently is "recently"?  And does VACUUM clean it up? -- Angular momentum makes the world go 'round.