Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uBU99-002Gqc-JP for pgsql-bugs@arkaria.postgresql.org; Sun, 04 May 2025 07:52:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uBU96-00HWQE-0l for pgsql-bugs@arkaria.postgresql.org; Sun, 04 May 2025 07:52:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uBU95-00HWQ5-Mj for pgsql-bugs@lists.postgresql.org; Sun, 04 May 2025 07:52:19 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uBU92-0004u8-2d for pgsql-bugs@lists.postgresql.org; Sun, 04 May 2025 07:52:19 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43cfdc2c8c9so13345025e9.2 for ; Sun, 04 May 2025 00:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746345135; x=1746949935; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=R977iP3S1FWJmrpoq0EZfQNEgazdz+U47jOZKLIZfIo=; b=IiJa6KvsUxqRPTv49d8O8yS6ojBKhhuAOjetaD1aoFlgKgSN54VOv2XxMcLoRBT06Q 4oM3G3xPascYav94F43Dvo5jcSFuIsUlN2DMlZotrfaGXNP86nYVd+qLIlzdCSeeQJUY 67UJYqpf0lkrejFwxgriLsmDIPQsEmkJlKMZRMeism45Wyx2WHG7yGQ6zMJtybnWSaix QWt+t31FOCITjeoU03+r3b3/c0ec1u8nYfTeU9Xk9RYso9bX1UZAmqxUjhAIFd+ZAfnl UvnDAS9jjfO4Vqpcwjjs2927+3WBuQfUzPnnnINqwKdQyf1cgE8a/nzhNdS9jM6wc0El vskQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746345135; x=1746949935; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=R977iP3S1FWJmrpoq0EZfQNEgazdz+U47jOZKLIZfIo=; b=aoh/IiMR6dJEMXszMmukq3zZRdHGCRzLPah00W3pL8LL3373K11wrevzJBV5c2tQCE TBjsjgvP0UQI4Ve/O1idk/VbVUMQsORxo/nPynMUi/ir+d9ILY0Wt6gUVTetMtFsNjJO U1hFlfL1uvt92pShltgFkVdAzIR12xMoaah3DHMOu/4RduAHsrnGUS1rWdvkB+kClvk0 cdO9xcXN/jEDsyDyQinDw9g5o2dCQbtpfnBfz96YAIVJpvYre8YGQgLIMNJ8O9Ke2XVi 7E7f+6BEfUn8Aby6m4IW3bSkq7h3zTdXcIZdLXX7HLTGN6rqsYb95U/KG4RK0UAXC5kY Yk9Q== X-Gm-Message-State: AOJu0YwD8PiDX7uRnWTjBypye2dIKyt0m00zKRAR0MkWkNp4NwVeNHXj VCZLAQ1TVX3U5ffSmDgRsVbJ4t00v1VNIQyCaqn6Llg6+7/qG/9o X-Gm-Gg: ASbGncuTQ7oiJYepgkcR0+GxNR0qLbtvDk5pg7f9n6cnrh9lXksCkA6XC/R79hmtALH bzzklQJMzryM5KA62Kb4WRa1/rFWwIXUXKYq+ykq+GZim532xlL7ftk1uhI18/MyX3grcjSgdIx F8Zza8ZNS7Kl2VnWy2PMyLL1M5Jwr9Fw5Dj6kjpE5FVAkdvT5F6ECbLe0ukYDBUfcCo2IWGv5EA +3pqJ7p8ctLx0K6r+5UWu3aofBoNgTOPm5eoBSLn62qtHII8kvXG74mKNNg+pRQvAIg2wXQXVHD xFpFRBFpiljmbHKIc96Bi3n4dtVub16oCBaKXwv5MPdu1x1VACx2aQ1lY6pbncSWLaG3Z5SgTOv 8YvnPg9zBlD4= X-Google-Smtp-Source: AGHT+IEA32sjV91MC0yDP259Py18g0VrGSMPKqNETwWiHBRHcPDD0AZwpIt+gHMJseiwp03Uo6QtlQ== X-Received: by 2002:a05:600c:1c29:b0:43d:fa58:700e with SMTP id 5b1f17b1804b1-441c1d73cd7mr26027675e9.33.1746345135004; Sun, 04 May 2025 00:52:15 -0700 (PDT) Received: from [192.168.0.211] (84.123.234.224.dyn.user.ono.com. [84.123.234.224]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a099ae7cbbsm6912610f8f.53.2025.05.04.00.52.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 May 2025 00:52:14 -0700 (PDT) Message-ID: <9691212b-86f0-4476-940e-2e4ba0dd0cf9@gmail.com> Date: Sun, 4 May 2025 09:52:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18909: Query creates millions of temporary files and stalls To: Sergey Koposov , "tgl@sss.pgh.pa.us" Cc: "pgsql-bugs@lists.postgresql.org" References: <18909-e5e1b702c9441b8a@postgresql.org> <2051617.1746223978@sss.pgh.pa.us> <5e98fba645682c40bf5f88ef858963ade9681956.camel@ed.ac.uk> <2177960.1746289626@sss.pgh.pa.us> <80bab58be182e80e73b5d5f71664ede9ce58f957.camel@ed.ac.uk> <8fc51cd7-115a-425a-828e-c99defb5afef@gmail.com> <0ce957be37434cfca4820d1e89a70cb2b456d3db.camel@ed.ac.uk> <2216372.1746309806@sss.pgh.pa.us> <2221240.1746312453@sss.pgh.pa.us> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/5/2025 01:05, Sergey Koposov wrote: > The only thing I can add is that panstarrs1bestneighbour is ordered on disk by source_id. I don't know if that can be relevant. Seems promising. May you show us how much NULLs generates underlying JOIN operator. I guess, in your example the query should be close to the following: SELECT count(*) FROM disk_sample1 d LEFT JOIN gaia_edr3_aux.panstarrs1bestneighbour AS gaps1 ON (gaps1.original_ext_source_id = d.objid) WHERE gaps1.original_ext_source_id IS NULL; And just to be sure, show us the number of NULLs that may be generated by alternative LEFT JOIN: SELECT count(*) FROM gaia_edr3_aux.panstarrs1bestneighbour AS gaps1 LEFT JOIN gaia_edr3.gaia_source AS g ON (g.source_id = gaps1.source_id) WHERE g.source_id IS NULL; Also, show please the current value of the GUC hash_mem_multiplier. -- regards, Andrei Lepikhov