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 1iFflG-000636-87 for pgsql-general@arkaria.postgresql.org; Wed, 02 Oct 2019 14:37: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 1iFflE-0003eL-Sx for pgsql-general@arkaria.postgresql.org; Wed, 02 Oct 2019 14:37:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFflE-0003eA-GD for pgsql-general@lists.postgresql.org; Wed, 02 Oct 2019 14:37:48 +0000 Received: from n3.nabble.com ([162.255.23.22]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iFflB-0002wd-Sp for pgsql-general@postgresql.org; Wed, 02 Oct 2019 14:37:47 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 082D3179CB6FA for ; Wed, 2 Oct 2019 07:37:44 -0700 (MST) Date: Wed, 2 Oct 2019 07:37:43 -0700 (MST) From: PegoraroF10 To: pgsql-general@postgresql.org Message-ID: <1570027063947-0.post@n3.nabble.com> Subject: Performance on JSONB select MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk select * from MyTable where ((JsonBField->>'status'='descartada' and To_Date(JsonBField->'descartada'->>'data','yyyy-mm-dd') > Current_Date) or (JsonBField->>'status'='contrato' and To_Date(JsonBField->'contrato'->>'data','yyyy-mm-dd') > Current_Date-7) or (JsonBField->>'status'='naoatribuido')); Considering this table has a million records, I would like to use a proper index, but how can I use an index when using operator >. -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html