Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f470b-0007Xr-7G for pgsql-general@arkaria.postgresql.org; Thu, 05 Apr 2018 15:41:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f470a-0006Dt-4k for pgsql-general@arkaria.postgresql.org; Thu, 05 Apr 2018 15:41:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f46wo-0008Pb-8w for pgsql-general@lists.postgresql.org; Thu, 05 Apr 2018 15:37:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f46wk-0001Pd-CY for pgsql-general@postgresql.org; Thu, 05 Apr 2018 15:37:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w35Fb1GC017893; Thu, 5 Apr 2018 11:37:01 -0400 From: Tom Lane To: adsj@novozymes.com (Adam =?utf-8?Q?Sj=C3=B8gren?=) cc: pgsql-general@postgresql.org Subject: Re: ERROR: unexpected chunk number 0 (expected 1) for toast value 76753264 in pg_toast_10920100 In-reply-to: <87k1tlel41.fsf@tullinup.koldfront.dk> References: <7pefuv53dl.fsf@novozymes.com> <871siqcdjh.fsf@tullinup.koldfront.dk> <87efmpllwg.fsf@tullinup.koldfront.dk> <20180117025021.GA39977@paquier.xyz> <874lnlc6ja.fsf@tullinup.koldfront.dk> <7632.1516209379@sss.pgh.pa.us> <87k1tlel41.fsf@tullinup.koldfront.dk> Comments: In-reply-to adsj@novozymes.com (Adam =?utf-8?Q?Sj=C3=B8gren?=) message dated "Thu, 05 Apr 2018 17:19:58 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17891.1522942621.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 05 Apr 2018 11:37:01 -0400 Message-ID: <17892.1522942621@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk adsj@novozymes.com (Adam =3D?utf-8?Q?Sj=3DC3=3DB8gren?=3D) writes: > Here's a statement which currently gives an unexpected chunk error: > efamroot@kat efam=3D# SELECT * FROM efam.sendreference WHERE id =3D '1= 89909908'; > ERROR: unexpected chunk number 0 (expected 1) for toast value 1698936= 148 in pg_toast_10919630 OK ... > And when I run the suggested query, I get: > efamroot@kat efam=3D# select chunk_id, chunk_seq, ctid, xmin, xmax, le= ngth(chunk_data) from pg_toast.pg_toast_10919630 where chunk_id =3D 169893= 6148 order by 1,2; > chunk_id | chunk_seq | ctid | xmin | xmax | length = > ------------+-----------+--------------+------------+------+-------- > 1698936148 | 0 | (52888694,2) | 1511390221 | 0 | 1996 > 1698936148 | 1 | (52888694,4) | 1511390221 | 0 | 1148 > (2 rows) Hmph. So if you EXPLAIN that query, does it show it's doing it as an indexscan? I'd expect so, but it's always good to make sure. Assuming it does say that, then the other test I had in mind would involve "set enable_indexscan =3D 0", then repeat the EXPLAIN to make sure that you now get a seqscan plan (you might need to turn off enable_bitmapscan too), then do the query again and see whether the results are the same. regards, tom lane