Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h44F0-0007mi-34 for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2019 13:48:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h44Ey-0003dr-St for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2019 13:48:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h44EJ-0000Jb-NT for pgsql-hackers@lists.postgresql.org; Wed, 13 Mar 2019 13:47:36 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h44EF-00019s-SR for pgsql-hackers@lists.postgresql.org; Wed, 13 Mar 2019 13:47:34 +0000 Received: by mail-wr1-x443.google.com with SMTP id d17so2066763wre.10 for ; Wed, 13 Mar 2019 06:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=o/RJWyLTN9i4s+fIrlXGxsh5EsXRYLvBPOlTgxL27Ak=; b=Xg865F5IKyBS8H013FruNeRiqXpi8VpcK385AL6QJyCfemuy/28bchv1Ke3DhTod+8 xAelwdbJizcHGw6WHldxjxLDcvnr9e/BheFWDJoFGDY6R/MLiEf/cD7D9beBhwHS8xrh JofXRpNUvezkcBUkq3WbMoG3k2D6KbNV68cHNYZh74DG+OPYOjXj6lo3zlLm/5OBkdZm vZox6BHtLv+IRCRbK6Gq1dPOEd6kFc2oj3VFVAQ59YPKzkyCQOEcBwEX0MRySSWmgJK7 hdCOQ396HWRTo9S/yuaQePgF0BIc5hPWMqAYYtWW9801g0ebyrWL2cNcerfETlftk2F5 Q+XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=o/RJWyLTN9i4s+fIrlXGxsh5EsXRYLvBPOlTgxL27Ak=; b=IiuaLHB41l5YHUaOhRYqy+cYjN9IqttiBpo4Jg1vp5gv6lSyaUcgLjEbaqHrci9+o4 1TO84M/eNi0RrDjVAvxkPd4LjecKhp5yMypqhLcLg6kTyIYD2pBX066v6G1xBPHiFIz1 i4d44Zs4iBe4uIBUn9/XXFnlXfW4xUyFiFqBY0y7+fsleArKgvRrWu8E4j/stWF2qctg LdDSY2OsXT62Sv1ZLnBRgkQoibBZE8DWfDX3tFMJCQCnC1xf7Tj2SIR9UPYPdbdR5FRg XDUNite1wuU/9NDpyMEK6IlRuh0WGBjoTcrrQesVW7E5rWUCB2ou39joFdx5lJ8r5fdC U79w== X-Gm-Message-State: APjAAAWxbN4IQNz8OgRkmjTPvPOYG3WLKolGoihYACi/jjcQrGVSY6aT 0PvgoRpdKNreeqU8R1xAtRGM1aW8Uye23LSoVmnBCpbFupXHsyarXNswcz5vPdT3vCTga+Y9gbR KDSqninfYfWg4c3vlZBIhzUuUyH7Ef/bmgaotSNtO2KHQPt+yRJfIj4SSfSvuWocONvaq06G0xH FlXUv8x1BTU0ea3FilKArkIg== X-Google-Smtp-Source: APXvYqxf6tLFNjOucVXTNh/AchrFYj2W2EOh0Th8xg2IKgBvZwriEhLNLmSpr5LyUJXJ6je101NY+g== X-Received: by 2002:adf:e442:: with SMTP id t2mr14672044wrm.256.1552484849817; Wed, 13 Mar 2019 06:47:29 -0700 (PDT) Received: from [10.137.0.18] (cst-prg-3-92.cust.vodafone.cz. [46.135.3.92]) by smtp.gmail.com with ESMTPSA id f13sm2277096wme.4.2019.03.13.06.47.27 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 06:47:28 -0700 (PDT) Subject: Re: performance issue in remove_from_unowned_list() To: Robert Haas Cc: Alvaro Herrera , Postgres hackers References: <20190310200923.GA4108@alvherre.pgsql> <7c599eff-8125-091c-61ef-90e02aa57486@2ndquadrant.com> From: Tomas Vondra Message-ID: <319fd982-2d28-5879-a8bb-75d1067e8980@2ndquadrant.com> Date: Wed, 13 Mar 2019 14:47:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/13/19 1:12 PM, Robert Haas wrote: > On Tue, Mar 12, 2019 at 6:54 PM Tomas Vondra > wrote: >> Attached is a patch adopting the dlist approach - it seems to be working >> quite fine, and is a bit cleaner than just slapping another pointer into >> the SMgrRelationData struct. So I'd say this is the way to go. > > What about using a data structure that supports O(1) lookups for any element? > > The current efforts all seem to revolve around correctly guessing from > which end of the list we are likely to delete stuff, but your research > suggests that we don't always make such guesses particularly well. > And it seems unnecessary. > Isn't the the doubly-linked list is doing exactly that? AFAICS we already maintain a hash table of the smgr relations, and we look them up in this table. We don't need to look them up in the list of unowned relations - the whole problem is that with the current single-linked list, we need to iterate the list anyway to update pointer in the preceding entry. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services