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 1izNfl-000717-EF for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2020 16:37:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1izNfk-0003e2-1i for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2020 16:37:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from <9erthalion6@gmail.com>) id 1izNfj-0003TS-N0 for pgsql-hackers@lists.postgresql.org; Wed, 05 Feb 2020 16:37:03 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1izNfc-0000T9-Pm for pgsql-hackers@postgresql.org; Wed, 05 Feb 2020 16:37:03 +0000 Received: by mail-wr1-x443.google.com with SMTP id a6so3495972wrx.12 for ; Wed, 05 Feb 2020 08:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=buRRZuco1GggHYRCKbMLUQe0Nfqs+o7IaHcehoBjc/o=; b=by/JB9b93mwjR0DJkmO2U3kJD8ZLcC8nOL6x1bVPxbsHvfxelj5OmCmuASsyxUkZmF SGCQbdsMkwkZCEVMMS4VjkYfJXI2BYUZPiSg8vDmYrBicCCp1RFl6Bg7TYweQ6j0UEHC 7x0ZOgBavt8bDdk/HP9/trFyWwjdycTTjSnvuMNKtmx/v9AIyiK5MfzXaaQLNNaqyPH7 RiZRyuDXUdvhdKKGVQ9nYs6iwqLEXPkS8Ftw/REYj2Ksgr3dmUwjiPEChX8Fb+ltdllt Ke+BNCwt0zaQ/8pHqPyX6ufaauyOjvockM+1/hTBz9mX3etyMQNkU8QuCkv+Olz6/pOj S91A== 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=buRRZuco1GggHYRCKbMLUQe0Nfqs+o7IaHcehoBjc/o=; b=qllZ3ax1dY9HOMZ7OzA/rXJKvXHPYjkKuAfwOG8l61OqC629qsb3LsTtKSd3jdOgWR bhatYpyXll8R/IyLVdAeGxswYVJTcxn2p8T0zvepooZ12cmX91KZH3WHd/Xrx9Nlxhq+ n4UE7IEU8BEmbftpRQtYozUq8p4k+ZfFChN8maWbVK/qdKy/RlOtymBJwyoPInsOOa17 UzNUxGemG3XoG1K9YK/d5WPvDjfHV8QRcFPslVbF7kdtlk4k90ORmpP7rhNjLdb/zDpx LtTByIy3yppqvia5x52bzB1q3/kb86zVh2xf4qXHLFae+0IN3hbIcvDhbA6Z3YDn1Rg6 JS3g== X-Gm-Message-State: APjAAAVduNmhD7mJoYQa4hKo3f+Rx3zrbeAmfuCcMVc7iTl77MI04vlM nbJIdW/kWvg+XNI69iGzba4= X-Google-Smtp-Source: APXvYqyhZL21UEsrEJlynFb21JFtQQyvC9vaPRpeslEKpcVdNnMgObHW5ZrEyCXruLikd/RMKD5hlw== X-Received: by 2002:adf:dd8a:: with SMTP id x10mr31026766wrl.117.1580920615814; Wed, 05 Feb 2020 08:36:55 -0800 (PST) Received: from localhost ([185.85.220.201]) by smtp.gmail.com with ESMTPSA id y7sm7824123wmd.1.2020.02.05.08.36.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2020 08:36:54 -0800 (PST) Date: Wed, 5 Feb 2020 17:37:30 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Floris Van Nee Cc: Peter Geoghegan , Jesper Pedersen , David Rowley , Tomas Vondra , Kyotaro Horiguchi , Alvaro Herrera , Thomas Munro , James Coleman , Rafia Sabih , Jeff Janes , Bhushan Uparkar , PostgreSQL-development , Alexander Korotkov Subject: Re: Index Skip Scan Message-ID: <20200205163730.eqvoxh6eb3do52r5@localhost> References: <20200121160942.eu4bvbu46nt223ug@localhost> <20200122160441.ograupmzyytde2mi@localhost> <1579713885361.64964@Optiver.com> <20200122213603.ndlm6t4ryivdwxs7@localhost> <20200127103016.ieflsboqveb6iduc@localhost> <20200204200205.ip5c2mzy3i2okqey@localhost> <5be025f30d8e45cda167c58b5d5e72d2@opammb0561.comp.optiver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5be025f30d8e45cda167c58b5d5e72d2@opammb0561.comp.optiver.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Tue, Feb 04, 2020 at 08:34:09PM +0000, Floris Van Nee wrote: > > > this point me and Jesper inclined to go with the second option. But maybe > > I'm missing something, are there any other suggestions? > > Unfortunately I figured this would need a more invasive fix. I tend to agree that it'd be better to not skip in situations like this. I think it'd make most sense to make any plan for these 'prepare/fetch' queries would not use skip, but rather a materialize node, right? Yes, sort of, without a skip scan it would be just an index only scan with unique on top. Actually it's not immediately clean how to achieve this, since at the moment, when planner is deciding to consider index skip scan, there is no information about neither direction nor whether we're dealing with a cursor. Maybe we can somehow signal to the decision logic that the root was a DeclareCursorStmt by e.g. introducing a new field to the query structure (or abusing an existing one, since DeclareCursorStmt is being processed by standard_ProcessUtility, just for a test I've tried to use utilityStmt of a nested statement hoping that it's unused and it didn't break tests yet).