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.92) (envelope-from ) id 1j9bdz-0007Fe-Od for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2020 21:33:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9bdy-000792-1b for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2020 21:33:30 +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 1j9bdx-00078v-Lc for pgsql-hackers@lists.postgresql.org; Wed, 04 Mar 2020 21:33:29 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j9bdv-0008JU-9t for pgsql-hackers@postgresql.org; Wed, 04 Mar 2020 21:33:28 +0000 Received: by mail-qt1-x843.google.com with SMTP id a4so2556821qto.12 for ; Wed, 04 Mar 2020 13:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=WF2bZ/RtOy6kVEX574DSOsP0aJBqoBBZm73BeN/K3KU=; b=npCWPt//8a82YQndAy7GlsF6X6knj0gSz2Hy9JeU2pVwb/+kXjvS2p6JR7WdgNVI/j ayEMGCNxd6hjFR5ZCv/L/Z5cDvdke0yH1SqUCmq1AA1pM5Q7sKbL6fJD7x7cqrdPnOOY 00cJjy8NH+b0oC+6l9mbSAAbb5gjSMbCUZ37mneHq81juMtmCMcT2NtiOhyUWgyUTeLO wICg31VEVZsy8hI0TRMQ8AxphaSsbJ+N7XXd4JhEFbXyF954LnWd6OBGMpaNymJpR6kk vluNzAHTGYUrntOw4WJxxolGES/DWFjOKG86vMETS5yslvrzxGFD/oG04eassC5iS3Yz eblA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=WF2bZ/RtOy6kVEX574DSOsP0aJBqoBBZm73BeN/K3KU=; b=Vyrcf9egVSKfm5oE0q7BOTUyvRJqtCQH8ZL3IBE7LArvkUpyOH4y4AmjhlQwgE7uNQ ZZxA4dMIo2j2Vq/uz8NKEUrl6+oDb53Nwq5K13ZXKYqShWngf0Y1+6SfMZcn5X1DiP07 tRcfcumn5vTKV1+h5casnLkG0IldjVobREvzYZ0kOmMvAN5mg4JxQN3P/ceX6IzZCJ0M nf/8qvwQX2Ry0VKA1IeXBY5OBTTBWOMLB17CJPeXn4hDKo1il2ReNSOyGrGOwSdrJc72 oanz0Y7t1gBCHb8AmZ0t0u0dFkV7dBoPQ3EuMQuC8p4Z5Ppljawk0AUrRkZ97xDG1sAy kaHg== X-Gm-Message-State: ANhLgQ2V7bdPpy4SZWbDjJ4Cv9dQaRzoIGrA6K7x6qEUZmvoIt2ZVTaU 2/zvn04QE836U4RR5zZuRFuxQw== X-Google-Smtp-Source: ADFU+vvuhQfK2hZwkjBzl/nBRE/igg4TWpPxihZiE/J9TpvJKddXD+rNPxqhp5xljOLQvso8bv9xHw== X-Received: by 2002:ac8:7b4c:: with SMTP id m12mr4335640qtu.387.1583357606432; Wed, 04 Mar 2020 13:33:26 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.31.1]) by smtp.gmail.com with ESMTPSA id w2sm14750731qto.73.2020.03.04.13.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 13:33:24 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id C019F3007D2; Wed, 4 Mar 2020 18:33:21 -0300 (-03) Date: Wed, 4 Mar 2020 18:33:21 -0300 From: Alvaro Herrera To: Paul A Jungwirth Cc: Tom Lane , Pavel Stehule , Jeff Davis , Pgsql Hackers Subject: Re: range_agg Message-ID: <20200304213321.GA23016@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200304022849.GA5402@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I came across an interesting thing, namely multirange_canonicalize()'s use of qsort_arg with a callback of range_compare(). range_compare() calls range_deserialize() (non-trivial parsing) for each input range; multirange_canonicalize() later does a few extra deserialize calls of its own. Call me a premature optimization guy if you will, but I think it makes sense to have a different struct (let's call it "InMemoryRange") which stores the parsed representation of each range; then we can deserialize all ranges up front, and use that as many times as needed, without having to deserialize each range every time. While I'm at this, why not name the new file simply multiranges.c instead of multirangetypes.c? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services