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 1j0RXK-000532-50 for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Feb 2020 14:56:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j0RXH-0006wJ-RC for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Feb 2020 14:56:43 +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 1j0RXH-0006wC-DT for pgsql-hackers@lists.postgresql.org; Sat, 08 Feb 2020 14:56:43 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j0RXE-0004HX-Ge for pgsql-hackers@postgresql.org; Sat, 08 Feb 2020 14:56:41 +0000 Received: by mail-wr1-x435.google.com with SMTP id t3so2263715wru.7 for ; Sat, 08 Feb 2020 06:56:40 -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:references:mime-version :content-disposition:in-reply-to; bh=DO9ep9frTk3i5VHK8Zfyu84Lja9NMfPgNi9fVAIpRU0=; b=ivm2qqbEodV4FgAI2sLcCED8wjG2H9LK2+NXfvXH7tbWvPlG4MX/lOXW5sSp1h2rP4 XB8w2rUhrFcM5uFpUmlih5HaS0hpuFYRsajC/TGau5oEZ7QQPcu5HTqkR2tDqZOiBDC7 dihVuq21IXpSX0ocqEFg2MEw07YLicTl/x7hTW6NnN/yktXNilSHTZSWjmz9ZvIGQXVK 9q05GXr5pCLAq7VQgFQ0D/bxONcLXpTofjTOSfMIJ/ZTlwpUGJ7GoVVBHqqccUuyoSxw j2U8gDggPLfJgYDDLBMHtbsMT0tjRn9DYz15SxFV11PfW2+YwK8x0sXVMVI5OfAM816G ek6g== 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:references :mime-version:content-disposition:in-reply-to; bh=DO9ep9frTk3i5VHK8Zfyu84Lja9NMfPgNi9fVAIpRU0=; b=nEnPwAcJXklVF2UX8/hQIGO3sJ8crK2fN5oSAxVUPIxqlS5jMPvKVFw1cK+y4lPJqQ LOvvz1PJQAthl1Cd7dwamK7nBPWbkBNJvI2zz58lJ8dCG5pl1WBxLdq323A5NHOanoIf f1BfLaXD2p09P46h6osycMR28frTsxZ3dQZbvmanOmXa6ucpcwCn4RYF0b2X5Zg6FJ6v tTXv8MyLoiAn2BYW7P4iXpAkb8xjHnHwIvSprSYKna2XxNytR9BaxF+gODTWgPqpXFNQ 3b1radQbwefXROGFhMBaFmgqY003WEf5n4yz8vs6ZPC9nfbM7EcZAkVirvAIVv4m7EPy A9jQ== X-Gm-Message-State: APjAAAWmgDTzBLRVHouR0qJ+FbSVOlNdOTQ9rGq21oed8sZqFjG6nuxD cNaJ5Wvn+h2BKm9PZFc+c6AnvQ== X-Google-Smtp-Source: APXvYqyUvm/9E7smriClMEdGesYkNzS7b1jfp0Fzt8FFoxavhCKB4mBP65w1CjKFgBeZa1nRdthDvw== X-Received: by 2002:adf:b648:: with SMTP id i8mr5651158wre.91.1581173798995; Sat, 08 Feb 2020 06:56:38 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id z19sm7481852wmi.35.2020.02.08.06.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2020 06:56:38 -0800 (PST) Date: Sat, 8 Feb 2020 15:56:35 +0100 From: Tomas Vondra To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: Kyotaro Horiguchi , florisvannee@optiver.com, pg@bowt.ie, jesper.pedersen@redhat.com, david.rowley@2ndquadrant.com, alvherre@2ndquadrant.com, thomas.munro@gmail.com, jtc331@gmail.com, rafia.pghackers@gmail.com, jeff.janes@gmail.com, bhushan.uparkar@gmail.com, pgsql-hackers@postgresql.org, a.korotkov@postgrespro.ru Subject: Re: Index Skip Scan Message-ID: <20200208145635.5cgmvgz2gsyvqpgj@development> References: <20200205163730.eqvoxh6eb3do52r5@localhost> <20200206.102450.1514793516830965023.horikyota.ntt@gmail.com> <20200206105707.fuidmdsi6oapieoz@localhost> <20200206.212220.642002310227620136.horikyota.ntt@gmail.com> <20200207162543.zlj2tvcwy7jku6vu@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200207162543.zlj2tvcwy7jku6vu@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk OK, A couple more comments based on quick review of the patch, particularly the part related to planning: 1) create_skipscan_unique_path has one assert commented out. Either it's something we want to enforce, or we should remove it. /*Assert(distinctPrefixKeys <= list_length(pathnode->path.pathkeys));*/ 2) I wonder if the current costing model is overly optimistic. We simply copy the startup cost from the IndexPath, which seems fine. But for total cost we do this: pathnode->path.total_cost = basepath->startup_cost * numGroups; which seems a bit too simplistic. The startup cost is pretty much just the cost to find the first item in the index, but surely we need to do more to find the next group - we need to do comparisons to skip some of the items, etc. If we think that's unnecessary, we need to explain it in a comment or somthing. 3) I don't think we should make planning dependent on hasDeclareCursor. 4) I'm not quite sure how sensible it's to create a new IndexPath in create_skipscan_unique_path. On the one hand it works, but I don't think any other path is constructed like this so I wonder if we're missing something. Perhaps it'd be better to just add a new path node on top of the IndexPath, and then handle this in create_plan. We already do something similar for Bitmap Index Scans, where we create a different executor node from IndexPath depending on the parent node. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services