Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ikYLS-0007mA-FN for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Dec 2019 18:58:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ikYLQ-0004N9-3B for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Dec 2019 18:58:48 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1ikYLP-0004N0-RK for pgsql-bugs@lists.postgresql.org; Thu, 26 Dec 2019 18:58:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ikYLI-0008Bo-HM for pgsql-bugs@lists.postgresql.org; Thu, 26 Dec 2019 18:58:46 +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 xBQIwZop004911; Thu, 26 Dec 2019 13:58:36 -0500 From: Tom Lane To: Zhihong Zhang cc: Jeff Janes , Tomas Vondra , pgsql-bugs Subject: Re: Indexing on JSONB field not working In-reply-to: <83E6A3F7-B1B4-4AD6-905A-BE11D244D35A@gmail.com> References: <0cf001d5b77f$bfe47e10$3fad7a30$@gmail.com> <20191220223005.f6w4ff4kdbgtanpz@development> <83E6A3F7-B1B4-4AD6-905A-BE11D244D35A@gmail.com> Comments: In-reply-to Zhihong Zhang message dated "Thu, 26 Dec 2019 11:58:27 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4909.1577386715.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 26 Dec 2019 13:58:35 -0500 Message-ID: <4910.1577386715@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Zhihong Zhang writes: > The index name is correct and I ran =E2=80=98analyze' multiple times sin= ce the index is created. I have dozen indexes, some are created when table= is created. None of them is in pg_stats. You still haven't shown us exactly what you're doing, only asserted that you're doing the right thing, which seems somewhat unlikely given that nobody has been able to reproduce this behavior based on what you've told us so far. One possible gotcha is indicated by this comment in analyze.c: * Open all indexes of the relation, and see if there are any analyzab= le * columns in the indexes. We do not analyze index columns if there w= as * an explicit column list in the ANALYZE command, however. If we are that is, if you did something like "ANALYZE assets(_doc);" it would not result in creation of stats for any expression indexes. > The database is on AWS RDS. Does that make any difference? Wouldn't have thought that their version of Postgres deviates much from community Postgres. If you were talking about Aurora or Redshift, I can't speak to what those do. regards, tom lane