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 1jZuGy-0002tH-7z for pgsql-general@arkaria.postgresql.org; Sat, 16 May 2020 10:42:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZuGv-0007oJ-H5 for pgsql-general@arkaria.postgresql.org; Sat, 16 May 2020 10:42:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZuGv-0007lb-2x for pgsql-general@lists.postgresql.org; Sat, 16 May 2020 10:42:25 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZuGn-0007VC-NF for pgsql-general@lists.postgresql.org; Sat, 16 May 2020 10:42:23 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 3297C308B; Sat, 16 May 2020 12:42:15 +0200 (CEST) Date: Sat, 16 May 2020 12:42:15 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Column reset all values Message-ID: <20200516104215.GB8152@hjp.at> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cvVnyQ+4j833TQvp" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --cvVnyQ+4j833TQvp Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-05-14 16:32:41 +0400, otar shavadze wrote: > also nor index drop is an option, because I need re-create index as I use= this > table in procedure, so index is necessary for=A0 further queries. So total > runtime will not decreased. A full index on a column where all the values are the same (NULL in this case) is useless. For querys which check for the existing value, the optimizer will notice that a full table scan is faster. For query which use any other value, you expect 0 results: So all the optimizer want to kno= w is that the value is indeed not in the column so that it can skip the table entirely. You can do that with a partial index (WHERE col IS NOT NULL) or maybe even a constraint. So I would drop the full index, update the table and then create a partial index. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --cvVnyQ+4j833TQvp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl6/w34ACgkQ8g5IURL+ KF0Mmw/+LswtsayCSEHTQCxoVVjuYvx3sQR56w3gOxAwNO26hKtz8+jrxMChH2tg MykOsdJmDXqX2Fk7bQMLuiR0rcUOFDVHF1KWwE+z3O40TZ9xaetHUvB3fYu+9t7B HcyLqiDszoppuadwmzjwva6H+FRpftKg+WLYoShuTqFPoQ48kWsS+YX9XhHh5kMp /K+k2gv1o8b1wrVgvfHi2yikhrPuFSLLt1PxttapfxZvx50zdb4Y2VOJlWMep4X6 0rziThMGNuaNwzISP631rew97xLyL6IbdoAb2tL5hL0o2hVKxPnlIWUrWWg6ps91 z6XEeEJK/lKeDUiJAKmrEee2zdTB5XGihYEngWZtiyXHCjehFNHBvjEX0LyMiR9E YJxHLv/AoV2NWPWcMaLSZRmkuW1S06PGqWFqbegTAb7/fnpwF+Z6nwATVTctNggi wsh7SYd5WsXm//AHEsx27vXsLMTOucpzdnN7DFJNto4iVL2o57Y/hzl6/ttp9cpE pDFqZecPb3Msyb3OQ+KXKlK222xRm8VNbdmSC2vQQBlGm4JNGZ76rVjMqI6nvXLL vLfyHj/dr+AEF1OKPxyo7VoudmsdvKj9S+SR9f/iQG2YlOXSyTUw5YZuVhoccTyf zhP6URtmlNbyQcN32cUS1VUDaL2PogjSgXpmvXjEjVDkdcRvtck= =4gRS -----END PGP SIGNATURE----- --cvVnyQ+4j833TQvp--