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 1kVw01-00049J-Er for pgsql-performance@arkaria.postgresql.org; Fri, 23 Oct 2020 12:16:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVw00-0006uG-EY for pgsql-performance@arkaria.postgresql.org; Fri, 23 Oct 2020 12:16:48 +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 1kVw00-0006sB-2V for pgsql-performance@lists.postgresql.org; Fri, 23 Oct 2020 12:16:48 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVvzx-0005mj-Lm for pgsql-performance@postgresql.org; Fri, 23 Oct 2020 12:16:47 +0000 Received: by mail-lf1-x141.google.com with SMTP id 184so1821958lfd.6 for ; Fri, 23 Oct 2020 05:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duneanalytics-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=hhBnvPtgEjWD5c3R+5+d7IqVNT5LIm3slAZeOvBeDDY=; b=aVb88yccF2BNbXiIBaYYa3XyTIlwqOFFqNS8d22yNoXq7ONrlQSTBKBWRRFI5K/1tk 2jYQi6frC/pPBm5UWqKjd/OR8xaU8JnLBLOR77Vwzv0JdaqyNc13RFaBGQlucnsk0gED sXnu/Y8v2HCwjE3GpRUZezOr7gQtuAhtJ2lthdLWL8JLtwzPeE4vPHfQshp+ywUuE7cS ZHR3ejnLdTiiaAh9DJdY/rcG4d42cXqa19zLQ8g21LFo0JPwPI11y4NUOvYfOdRFhgHU jqCqF+z4IbFBCtVKDiFwQ78i+5PUkvUjyGzSOsoi1Z+rNNC+IIwOHQZ/pzTYIRAv65TC gZWA== 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-transfer-encoding :content-language; bh=hhBnvPtgEjWD5c3R+5+d7IqVNT5LIm3slAZeOvBeDDY=; b=Uq6+Pg0mHyQ0UjXYNCcEwMBnTW2ZlpLLudfV0OFH7/+zA8oXc2LRXzcQ6G/F52sG/4 AyuDBarqU/3S2urZ7wD60zjhlEu6MwHzXrHkjuNClYRgXdysWnEdJZnKWsvCMwdiHuOt rZhMhaU1DOJhdz0T0a1rc+p07aY5GPxQWQzzw/W/WTx5IGoTwjP5ocamMNpfLQyRgDdm Nx0rlM3eCO36T6NAWKp0n7KJ86dS5CqgAZlFOAhKWsEUih3HH5agTPn4zME7V96khumj 8qrgzNZ+P/Im3+crb3ue58+hlLzwR61P84B25apd9EFnNpaouWOKjG+ZMvTplzWBWs5/ 0LdA== X-Gm-Message-State: AOAM531/RIVFsC9UyFQYQSQotKSuKDyac+uMa++LWsPc/6xGjvuz3MRg laU2g/s430EgVM4xjyd5q0oNqWIH0ut17Xix X-Google-Smtp-Source: ABdhPJyiBPsfF6gpG/POIIBkfbUQX2kRvzO6yP5xtNg9/MENy3kPjtJmm66r3BJyZj05wGCLGIQmmA== X-Received: by 2002:ac2:4e90:: with SMTP id o16mr716127lfr.251.1603455402583; Fri, 23 Oct 2020 05:16:42 -0700 (PDT) Received: from [192.168.1.181] (host-37-191-238-241.lynet.no. [37.191.238.241]) by smtp.gmail.com with ESMTPSA id y19sm148026ljc.4.2020.10.23.05.16.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 05:16:41 -0700 (PDT) Subject: Re: Query Performance / Planner estimate off To: Justin Pryzby Cc: Sebastian Dressler , pgsql-performance@postgresql.org References: <61c9fd35-bdb8-3fe6-bda0-81c7e6a9eaf8@duneanalytics.com> <20201022063701.GU9241@telsasoft.com> <7f586824-0d53-0f84-15f1-f460dbc414b5@duneanalytics.com> <20201022134826.GV9241@telsasoft.com> From: Mats Olsen Message-ID: Date: Fri, 23 Oct 2020 14:16:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <20201022134826.GV9241@telsasoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thanks for your response Justin. On 10/22/20 3:48 PM, Justin Pryzby wrote: > On Thu, Oct 22, 2020 at 09:36:03AM +0200, Mats Olsen wrote: >> On 10/22/20 8:37 AM, Justin Pryzby wrote: >>> These look redundant (which doesn't matter for this the query): >>> >>> Partition key: RANGE (block_number) >>> Indexes: >>> "transactions_block_number_btree" btree (block_number DESC) >>> "transactions_block_number_hash_key" UNIQUE CONSTRAINT, btree (block_number, hash) >>> "transactions_block_number_time" btree (hash, block_number) >>> >>> Maybe that would be an index just on "hash", which might help here. >>> >>> Possibly you'd want to try to use a BRIN index on timestamp (or maybe >>> block_number?). >> Yeah this could be a good idea, but the size of this table doesn't let me >> add any indexes while it's online. I'll revisit these the next time we >> redeploy the database. > Why not CREATE INDEX CONCURRENTLY ? We could, but it would take forever on the `ethereum.transactions` table. > It seems to me you could add BRIN on all correlated indexes. It's nearly free. > > 0.102922715 | Pair_evt_Mint | evt_block_time | f | 0 | -0.56466025 | 10000 | 10001 | 0.964666 > 0.06872191 | Pair_evt_Mint | evt_block_time | f | 0 | -0.8379525 | 500 | 501 | 0.99982 > 0.06872191 | Pair_evt_Mint | evt_block_number | f | 0 | -0.8379525 | 500 | 501 | 0.99982 > 0.032878816 | Pair_evt_Mint | evt_block_number | f | 0 | -0.56466025 | 2500 | 2501 | 0.964666 Agreed, could try to add BRIN's on these. > >>> Maybe you'd want to VACUUM the table to allow index-only scan on the hash >>> columns ? > Did you try it ? I think this could be a big win. > Since it's append-only, autovacuum won't hit it (until you upgrade to pg13). I vacuumed the uniswap_v2."Pair_evt_Mint", but still getting the same plan, unfortunately. >