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 1oQz4i-0000nd-FS for pgsql-admin@arkaria.postgresql.org; Wed, 24 Aug 2022 22:42:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oQz3j-0007j7-CT for pgsql-admin@arkaria.postgresql.org; Wed, 24 Aug 2022 22:41:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQz3i-0007gU-VC for pgsql-admin@lists.postgresql.org; Wed, 24 Aug 2022 22:41:15 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oQz3g-0000DK-Nx for pgsql-admin@lists.postgresql.org; Wed, 24 Aug 2022 22:41:14 +0000 Received: by mail-pg1-x532.google.com with SMTP id f4so14424153pgc.12 for ; Wed, 24 Aug 2022 15:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:message-id:subject:date:mime-version:from :content-transfer-encoding:from:to:cc; bh=3thfDIRmqixQv2xVfHRVPNKyrmdDbxKeD8BswwG/EZU=; b=mIQlEOpg+EzJ62cajFusnznEI+Rk+hr1fVghUM/kyUVP0y6QU3koxK2/ej+f24aGGH hffPOKgFESJUwavJ+lL4LyvW+vGRuXkAKbuXMXBXvrasScVWauNqI60o7fqH94zoklCq 5AcZRfEXhwrI16ne4GGjkoZ18vc25+qEQK574MKSUZPa+nBounQINdqpZuHGSSlQiXPt Ai60RcRqzV7upjmHkYa5GtxJudZtmJXBxE/TMVMCekJijVbzcEOqq6wwsP1vGzx0iwwT HetVXxVhEThqvY2ct07l6TDw/LPj0sUi7cIB54yK78hif1vUdtBoXhZ0TBTiE2wdh/kM KsXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:message-id:subject:date:mime-version:from :content-transfer-encoding:x-gm-message-state:from:to:cc; bh=3thfDIRmqixQv2xVfHRVPNKyrmdDbxKeD8BswwG/EZU=; b=O/wBHLpfgpm7VPrh4dtINr4XCHshZq9i735KyPHo6wNSOtxkpFqKLNuxvm5HcomuYl aVQ0oMjH59UcBi8d2JzFoORklK84Ui8HJeEtG7zDPCZQ4Ahz3WkErcuspMokRnn2hNGb nQtC9zhUqY1/cosVd9rIz2hxqSVrN8CE1AEiH/CRW81xuWWc+remFdxL1AeCYqqkQud6 5dM7cETDZvElcLR4GCj/J8M/Z30sH+jdbcMPc0SJoJNsYAbevMyj0i6hv4F8HYiBP/+j pMfAIW9mnlxTbGK7gvtGC+jWjLbHom3ezcW1ojmVTlX1soWS0IOL6gAhCzmzLiXwsqfK rZRA== X-Gm-Message-State: ACgBeo2GUKkUXfUDj0BMaM1OMPd2h2fbmdnGodL3FdxP14U28AGuNemT Q21xC4B15/SJhWT4B39DRcc68R5xHVk= X-Google-Smtp-Source: AA6agR6/5UoVuOTYJE9Yi+9f9hzVw1+A6gd1tInGKLCl7svkFDH300WLaw3K/ifBAuizuX8T5cjd0Q== X-Received: by 2002:a05:6a00:4c92:b0:536:ac94:e8b0 with SMTP id eb18-20020a056a004c9200b00536ac94e8b0mr1156710pfb.13.1661380869725; Wed, 24 Aug 2022 15:41:09 -0700 (PDT) Received: from smtpclient.apple ([4.42.177.235]) by smtp.gmail.com with ESMTPSA id oa2-20020a17090b1bc200b001fb0fc33d72sm1934072pjb.47.2022.08.24.15.41.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Aug 2022 15:41:09 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Teja Jakkidi Mime-Version: 1.0 (1.0) Date: Wed, 24 Aug 2022 15:41:08 -0700 Subject: Performance issue after creating partitions Message-Id: <10FAC7AB-09D1-4013-BB3C-79AA3AEDE374@gmail.com> To: pgsql-admin X-Mailer: iPhone Mail (19G71) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Admin team, We have a Postgres 13 server set up on Google Cloud. Recently we created par= titions as below for the tables: Range on =E2=80=98order_date=E2=80=99 column List on =E2=80=98country_code=E2=80=99 column =20 Quarterly partitions for range. Order date column is a time stamp column and when we are using this column a= s a filter in where condition : trunc(order_date) =3D to_date(=E2=80=992022-= 04-01=E2=80=99,=E2=80=99YYYY-MM-DD=E2=80=99), the query scans all the partit= ions dated back from the year 2000. So, instead of going to the 2022 Q2 part= ition directly, the query is scanning all the partitions. But when we remove the trunc() function and just specify order_date =3D=E2=80= =982022-04-01 07:02:30=E2=80=99, this works as expected. It goes to the corr= ect partition directly and gets the data.=20 Can Anyone help me on what=E2=80=99s happening in the first case and why all= the partitions are being scanned? For the first case, when there is a non partition table, it is behaving way b= etter. Thanks, J. Teja.=