pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Column reset all values
Date: Sat, 16 May 2020 12:42:15 +0200
Message-ID: <20200516104215.GB8152@hjp.at> (raw)
In-Reply-To: <CAG-jOyCoSp7Vy8TR_e8qa+14QQN+5cPzHfhUp4NG9JwgzE4QUQ@mail.gmail.com>
References: <CAG-jOyDg7TZ_x1rsL=URVc51sPxfNvi1YMWsLQmeqT1eCtVsTg@mail.gmail.com>
	<CAJ7S9TWpJRmxg10kxJu4-DKLQXy7BvZEDFd_Ec0bkWF16CTa7g@mail.gmail.com>
	<CAG-jOyCoSp7Vy8TR_e8qa+14QQN+5cPzHfhUp4NG9JwgzE4QUQ@mail.gmail.com>

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Ā  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 know 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

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (5+ messages)

Message-ID: <20200516104215.GB8152@hjp.at>
Permalink:  ../20200516104215.GB8152@hjp.at/
Also on:    postgresql.org/message-id/20200516104215.GB8152@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Column reset all values
  In-Reply-To: <20200516104215.GB8152@hjp.at>
  References: <CAG-jOyDg7TZ_x1rsL=URVc51sPxfNvi1YMWsLQmeqT1eCtVsTg@mail.gmail.com> <CAJ7S9TWpJRmxg10kxJu4-DKLQXy7BvZEDFd_Ec0bkWF16CTa7g@mail.gmail.com> <CAG-jOyCoSp7Vy8TR_e8qa+14QQN+5cPzHfhUp4NG9JwgzE4QUQ@mail.gmail.com> <20200516104215.GB8152@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox