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 1pBcfM-0005Nb-RF for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Dec 2022 14:16:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pBcfL-0000Ac-9q for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Dec 2022 14:16:51 +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 1pBcfK-0000AQ-Eb for pgsql-hackers@lists.postgresql.org; Sat, 31 Dec 2022 14:16:50 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pBcfD-0001bT-6m for pgsql-hackers@lists.postgresql.org; Sat, 31 Dec 2022 14:16:49 +0000 Received: by mail-wm1-x335.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so17276353wms.4 for ; Sat, 31 Dec 2022 06:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=m3hFpMDzcBDpbijaS+LkA66NL8frBfPHUHgBhcnitJw=; b=I70Z3IP4UiXilHcNhh4lx0P0Pitc3KvramGGJRq44alNBxAj5uHpfdAH0vOoPb60sQ QdKZcwzs5vG12oPOfwDODRi4VgY1zzmJtzvzhNHcDQ7aEK5b1gZ4vex78y7fQ8f83GtM qs2fPDO4XmsliFcA1a1Qe9qu4k0Ve8Hgx5FDsQxahcQhXw7YWDnG/sOBVEABJQP0Tftv DOodFJN76H8pUGu6ZeqiPL3BYY3/JsrdhpNOM7vjeWY1E7LYKsCC12JQjsuw93+m2WCi 93WTwW27gJJyA+mOLk56hgxvxDogqKIGuAmchqNEhb2q1cNnb8mOyeVRcBmjefdUL0sM pxZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m3hFpMDzcBDpbijaS+LkA66NL8frBfPHUHgBhcnitJw=; b=PyFWl1AGi4peW/m80swVi/+Y5ouXkySYhKJmxSnGLNdJgDz9+kRsbpPV4cAVef62Cm oJHkRdd9Q9Jdv/0QhExRSBcknDpdaAoJS0qKXKAlJUpGqtzVhOqQuLuM+ImgOVWnvsFU H1EnAg5oXJfv++bIOOfzQuTmoEqb/6qvtpvotkXKv0hIUK9p3W7DuKQ5WBT+2G9Hfffu sfcpoq0DmikVMvBC8RvKjq0btlprhLJ8RW+Wp5hd4MZwAbAKQ96HFpupV5RIPdT1/Cju OGGQ4lVilikhuAcXlfutuWdbHGlHk3mcY4k6J+7tyMwVeuU5ri4wT+wM0yy0VQvKzpwC I0LA== X-Gm-Message-State: AFqh2krO7ChYpjsCIu+zI/RH6NkVsd2wrbL2AOhySAA9We0N58Yzk55O cmffGv5HOSEmfxUO2dKxib8KbfzqQ43vYZKQq/xYO04MDWKqNf27YhbtS+oQc41p1Wyl1bcDTa2 E3v+uYKGzi4Xb5ZxQVg9dQkqJGTn8Q8Z7I8qlTRTKn/tY2mIJfolLBQZjKbAbD2jfLq8ez5PG7X iCVoadBPVLTkaYi2itnOMUzb9qP6xsRJJFR0fN+Rfr14QMyhdraksXttAFDDBsU6amDmt+DQYOB 2BCu9errF7q/lb+US4RYYd8K0k3iBNYcWcSL3I3tPxWra7w+y96SU7UntPC X-Google-Smtp-Source: AMrXdXuGcxKruWi7i/CyxRKMdnqJkm6UoYUFrFzfAdu6SVQ35g9jj7uKhJsouqwJX3g9G0d+a2cmuw== X-Received: by 2002:a7b:c7c8:0:b0:3d7:889:7496 with SMTP id z8-20020a7bc7c8000000b003d708897496mr24646404wmk.17.1672496200618; Sat, 31 Dec 2022 06:16:40 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-228-162.bb.vodafone.cz. [86.49.228.162]) by smtp.gmail.com with ESMTPSA id f14-20020adfe90e000000b002365730eae8sm23356894wrm.55.2022.12.31.06.16.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Dec 2022 06:16:40 -0800 (PST) Message-ID: <233ee0b3-4da0-3370-cd0b-1b8528851ddd@enterprisedb.com> Date: Sat, 31 Dec 2022 15:16:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: postgres_fdw: using TABLESAMPLE to collect remote sample To: Tom Lane Cc: James Finnerty , pgsql-hackers@lists.postgresql.org References: <151e835f-55d6-ddbc-b5b4-07ee606aba44@enterprisedb.com> <03182011-10a4-97b4-7c70-d99aa1c11eed@enterprisedb.com> <167112207543.1120.12195641719862911275.pgcf@coridan.postgresql.org> <3377008.1671122816@sss.pgh.pa.us> <6da357b0-fdd3-095d-a06c-87666f4a5a8c@enterprisedb.com> <951485.1672461744@sss.pgh.pa.us> Content-Language: en-US From: Tomas Vondra In-Reply-To: <951485.1672461744@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/31/22 05:42, Tom Lane wrote: > Tomas Vondra writes: >> After thinking about it a bit more I decided to rip out the 10% sampling >> rate inflation. > > +1. I'm not sure if there's anything more we need to do there, but > that didn't seem like that was it. > > I notice that the committed patch still has a reference to that hack > though: > > + * Ensure the sampling rate is between 0.0 and 1.0, even after the > + * 10% adjustment above. (Clamping to 0.0 is just paranoia.) > > Clamping still seems like a wise idea, but the comment is just > confusing now. > Yeah, I missed that reference. Will fix. > Also, I wonder if there is any possibility of ANALYZE failing > with > > ERROR: TABLESAMPLE clause can only be applied to tables and materialized views > > I think the patch avoids that, but only accidentally, because > reltuples will be 0 or -1 for a view. Maybe it'd be a good > idea to pull back relkind along with reltuples, and check > that too? Not sure. I guess we can rely on reltuples being 0 or -1 in such cases, but maybe it'd be good to at least mention that in a comment? We're not going to use other reltuples values for views etc. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company