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 1lCpUd-0000ZV-Ju for pgsql-admin@arkaria.postgresql.org; Thu, 18 Feb 2021 20:01:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lCpUc-0001n2-F4 for pgsql-admin@arkaria.postgresql.org; Thu, 18 Feb 2021 20:01:42 +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 1lCpUc-0001mv-5a for pgsql-admin@lists.postgresql.org; Thu, 18 Feb 2021 20:01:42 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lCpUZ-0005eq-Kr for pgsql-admin@lists.postgresql.org; Thu, 18 Feb 2021 20:01:41 +0000 Received: by mail-ot1-x336.google.com with SMTP id o10so2984589ote.13 for ; Thu, 18 Feb 2021 12:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=h3V+4BZCOVDdKGuWUDAJIVsf/BimXrWqPG+g33bek5I=; b=HiHFAiiXtwF1KdCjARE78hykzMxgtCFiek9HGYLGBwfjtxxa3Ol/ouAgBnfpoki7Ts Ymz6ukx9kdixWtA4yllUAe9/9OOrvrGxDsprbF9OSa8UDGmZ9RHMySpFY+fV1bgkqClA u30SJ47KUm1+v8ceM6PK4PI/xtgOzEBStmBXyVXMhUGQJsyHqf78OFC7PN/4fCxVUDgm WthGTk4qzHoMuqy61kuUdcL0YRKPj4JiEy2aVAlDuD5LwTPgsqeq1n69KW3lquv6+/1S CDlwqqhHw0kMIperLomrx4j/NrFSgXMU3+lLTS7YJVIwxHtngZ6pWwg7l+zL5Ffbtmyz uIkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=h3V+4BZCOVDdKGuWUDAJIVsf/BimXrWqPG+g33bek5I=; b=WgqGt3Jl6PZLDYmoz490eIZ7QmQS6+5+pZ90afFcfeKerVae7ZfwA0C4n7t/3RUH+z gNIosT3dG1qWgelBLbyh+U4MiS5prBOgLJlt6JdzKjeHyrp7cemb9zj2oQNvUQ7WCHaS BMbEXR0c/y8v8VnJOnejvkwvTlVGVYlOu9pv+yFnsp0fJiDAs5teyKxSo+4bPmCE+9iH AVYREeCjaxNxwkeMNyhQRLaCQ88LzqKuam57dNnzcDTdYXtSoIuAB1B9WmqNxH87S06Y GJZKrZkm2zMqpUvgNpKDBelMjU5ryLhYbILHsrgxDHb8k/nY+lw3lmDDKlE2k1hcogKY UR4g== X-Gm-Message-State: AOAM533sTOZHvi3hC/mtoYgAyGE3NZ0KKwVKqB/8ZiSWaUP8ouiaR+fT 61hX/vZOa26qgycGN/1giV1dMVVrqK4Bqw== X-Google-Smtp-Source: ABdhPJwMau7cyVK5dF2IGJXqbyEfUxly/X0XDAP8/dt/4L/9x9zpL+8eZ0YSXDXJwns/b2Pdu8vIOA== X-Received: by 2002:a05:6830:3152:: with SMTP id c18mr4177242ots.191.1613678497218; Thu, 18 Feb 2021 12:01:37 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id g11sm1433733oif.9.2021.02.18.12.01.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Feb 2021 12:01:36 -0800 (PST) Subject: Re: Disabling indexes on a table To: pgsql-admin@lists.postgresql.org References: <8D9636C9-D38E-4857-A542-1469A11A25FF@gmail.com> From: Ron Message-ID: <9e9e980a-a11e-ad06-2c81-b6f0f7cd8b5f@gmail.com> Date: Thu, 18 Feb 2021 14:01:35 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8D9636C9-D38E-4857-A542-1469A11A25FF@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/18/21 10:24 AM, John Scalia wrote: > One of my developers asked me about this, and he suggested running the following update: > > UPDATE pg_index SET indisready=false > WHERE indrelid = (select oid from pg_class where release = ‘his_table’); He found that on the Internet: https://fle.github.io/temporarily-disable-all-indexes-of-a-postgresql-table.html > I told him it’s never a good idea to update anything in a system catalog by hand, but that I would reach out here for a better opinion. Am I correct that he shouldn’t try this, or is he OK to do this? His table has approximately 8 different indexes on it, and those really slow down his bulk loads. Usually when I have to get involved, I just drop his indexes and rebuild them afterwards, and I know that is always safe. Disabling indices "just" saves having to run X number of CREATE INDEX statements, which is nothing to sneeze at since it's one less place to have to remember to update:  "REINDEX ;" just handles it all. Just as importantly, the index you want to drop might be a PK supporting a FK. (Postgresql really needs ALTER INDEX ... DISABLE and ALTER TABLE ... DISABLE ALL INDEXES;" statements.) -- Angular momentum makes the world go 'round.