Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YwuBO-0001dw-1g for pgsql-bugs@arkaria.postgresql.org; Mon, 25 May 2015 15:20:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YwuBN-0005sS-6S for pgsql-bugs@arkaria.postgresql.org; Mon, 25 May 2015 15:20:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ywidf-0007eg-7E for pgsql-bugs@postgresql.org; Mon, 25 May 2015 03:01:15 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1YwidV-00010S-QP for pgsql-bugs@postgresql.org; Mon, 25 May 2015 03:01:12 +0000 MIME-Version: 1.0 Subject: BUG #13348: PostgreSQL 9.5 sampletable BUG return rows not the same as reltuples*sample factor? To: pgsql-bugs@postgresql.org From: digoal@126.com Date: Mon, 25 May 2015 03:00:07 +0000 Message-ID: <20150525030007.17710.95359@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13348 Logged by: digoal Email address: digoal@126.com PostgreSQL version: Unsupported/Unknown Operating system: CentOS 6.x x64 Description: when use system sample method , it's return block's all row. yes ,it's correct by PostgreSQL doc desc. But when use BERNOULLI sample method, it's return rows not the same as reltuples*factor. Can we add filter to exact return rows equal to reltuples*factor ? postgres=# create table test(id int); CREATE TABLE postgres=# insert into test select generate_series(1,100000000); INSERT 0 100000000 Time: 128199.864 ms postgres=# select count(*) from test tablesample system (0.000001); count ------- 909 (1 row) Time: 1.930 ms postgres=# select 100000000*0.000001; ?column? ------------ 100.000000 (1 row) Time: 0.631 ms postgres=# select count(*) from (select ctid,* from test limit 100000) t where ctid::text ~ '\(1,'; count ------- 909 (1 row) Time: 196.232 ms but postgres=# select relpages,reltuples from pg_class where relname='test'; relpages | reltuples ----------+------------- 110012 | 2.72691e+07 (1 row) Time: 0.786 ms postgres=# select count(*) from test; count ----------- 100000000 (1 row) Time: 12041.390 ms postgres=# select count(*) from test tablesample BERNOULLI (0.000001) ; count ------- 1 (1 row) Time: 6245.059 ms postgres=# select count(*) from test tablesample BERNOULLI (0.00001) ; count ------- 13 (1 row) Time: 6305.808 ms postgres=# select 2.72691e+07*0.00001; ?column? ----------- 272.69100 (1 row) postgres=# vacuum analyze test; VACUUM Time: 9880.728 ms postgres=# select relpages,reltuples from pg_class where relname='test'; relpages | reltuples ----------+----------- 110012 | 1e+08 (1 row) Time: 0.438 ms postgres=# select count(*) from test tablesample BERNOULLI (0.00001) ; count ------- 6 (1 row) Time: 6243.548 ms postgres=# select count(*) from test tablesample BERNOULLI (0.00001) ; count ------- 9 (1 row) Time: 6275.948 ms postgres=# select count(*) from test tablesample BERNOULLI (0.00001) ; count ------- 9 (1 row) Time: 6243.882 ms -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs