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 1kkaiN-000088-L3 for pgsql-general@arkaria.postgresql.org; Wed, 02 Dec 2020 22:35:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kkaiM-0004NJ-K3 for pgsql-general@arkaria.postgresql.org; Wed, 02 Dec 2020 22:35:10 +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 1kkaiM-0004NC-8t for pgsql-general@lists.postgresql.org; Wed, 02 Dec 2020 22:35:10 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kkaiK-0006B5-1I for pgsql-general@lists.postgresql.org; Wed, 02 Dec 2020 22:35:09 +0000 Received: by mail-ot1-x333.google.com with SMTP id z24so3215837oto.6 for ; Wed, 02 Dec 2020 14:35:07 -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=Q0IexLYRIedJbnLZUrukcv2eDJiVR1rIe78krElkAPQ=; b=Q8U7NIKf7WnefwuBK+4Wc4+f63K6wwcEs6y1UNUcyxHmcStttM8qhvBjL0yXMfHYWc khkYHIw4zMvMkhaaNreLFyJ7TIgLyzZcr4y1G6gmSDeOshHtTpfs2JkOLQKcle+fwa7K pkneC6TKOMcjfk/kygUY/z+M8ifTH4Nxn9V3+3+oC3XSyoBZSBPkuS5H2BQpZf6cePEQ 7bxrSRJhipd1hGuFEgQI0ZmhTs1YOJqwjuj6Ubt1AQQdYtskKLZ/C6d2xIVP/uBsjoDZ GdbIGM2U2yyYh+O9SIWJSwshwQ/Yu+vGC9c0UEMM3JEj6Lwak5ev+xDGIUfmz5cQ6jK1 ioag== 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=Q0IexLYRIedJbnLZUrukcv2eDJiVR1rIe78krElkAPQ=; b=iRTajdbqWfogqHE5fsMxk4d0+/P+YpC9GjnswvnyqU4zdvescGrFhLuCOUoO0o3So6 oR2oHDdS+kk8xMWqj+gGCZ8lYFFw7vDP/NTUxxMphoCbpo5KYH0TGiovqqX/Po5wLzEr 4BDrv8cgC+QLjuGC1nGehDRD18Vu1B3gCoY9qBpbaSkOrWelIS/Xy+0E09Vus0r4tiac 6MWQVnEuSmAxkH4mkBoTrKZhkpHlxx+IOBhPhTawRpQQNmbDrLpA8xa4oc+woRAwbRg8 c1y7Jlrmi6eQa9fVaBK2d/NRWyTYxbwg5OUv6txN3Pr4JMszHapZ0QxaWAov44jrGmOk YbYg== X-Gm-Message-State: AOAM53194vTwkh4tBSgvbQ3WLG4LiNOK03qp3sD/QRgP/bUBScVtjvlc ewRO5lgCjOUIOTZEM4SjvGkU1W/ckR/mcw== X-Google-Smtp-Source: ABdhPJxBt16YVIvc1te4pyCmgGVi57pKVSf8OToSCldGf38fLGzmUMxho2rSpkMEaM92JEiIug7A4g== X-Received: by 2002:a05:6830:15d9:: with SMTP id j25mr39736otr.259.1606948506912; Wed, 02 Dec 2020 14:35:06 -0800 (PST) Received: from [192.168.1.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id v207sm705581oif.58.2020.12.02.14.35.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2020 14:35:06 -0800 (PST) Subject: Re: Is the Halloween problem an issue in Postgres To: pgsql-general@lists.postgresql.org References: <756bd845-ebe1-4c45-88e8-0ab44bbc02b7@Spark> <5f7e3d0e-52da-c5e4-72d6-edcff340d710@gmx.net> <869172f6-9114-e759-79ba-eb17f1c5082c@aklaver.com> <20201202222342.oc4ayyaxql24tquo@raf.org> From: Ron Message-ID: <4fcb3891-5496-3b14-7cc1-f42f08a3c09a@gmail.com> Date: Wed, 2 Dec 2020 16:35:05 -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: <20201202222342.oc4ayyaxql24tquo@raf.org> 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 12/2/20 4:23 PM, raf wrote: > On Wed, Dec 02, 2020 at 02:08:41PM -0800, Adrian Klaver wrote: > >> On 12/2/20 2:02 PM, Thomas Kellerer wrote: >>> guyren@icloud.com schrieb am 02.12.2020 um 21:27: >>>> The Halloween problem is that it is a challenge for the database if >>>> you’re updating a field that is also in the WHERE clause of the same >>>> query. >>>> >>>> I just saw a presentation from someone about how in SQL Server he >>>> recommended writing changes to a temp table and then writing them to >>>> the table as being much more efficient. >>> It sounds strange to me, that this _is_ actually a problem. >>> >>> Why exactly is that a problem in SQL Server? >> Yeah that was a new one to me. A quick search found: >> >> https://www.sqlshack.com/the-halloween-problem-in-sql-server-and-suggested-solutions/ >> >>> And what are the consequences if you do it nevertheless. > It looks like the anser is no (unless I've misunderstood the problem): > > create table a (id serial not null primary key, a integer not null, b integer not null); > create index a_a on a(a); > insert into a (a, b) values (1, 2); > insert into a (a, b) values (2, 3); > insert into a (a, b) values (3, 4); > insert into a (a, b) values (4, 5); > insert into a (a, b) values (5, 6); > insert into a (a, b) values (6, 7); > update a set a = a + 1 where a < 4; > select * from a order by id; > drop table a cascade; > > results in: > > id | a | b > ----+---+--- > 1 | 2 | 2 > 2 | 3 | 3 > 3 | 4 | 4 > 4 | 4 | 5 > 5 | 5 | 6 > 6 | 6 | 7 > > It's the same with or without the index on a(a). The Halloween Problem does not seem to cause the statement to fail, but to run slowly. -- Angular momentum makes the world go 'round.