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 1hf2Ga-0004ow-I6 for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Jun 2019 13:10:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hf2GX-0007ky-O3 for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Jun 2019 13:10:41 +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 1hf2GX-0007kr-8Y for pgsql-hackers@lists.postgresql.org; Sun, 23 Jun 2019 13:10:41 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hf2GS-0000R8-PH for pgsql-hackers@postgresql.org; Sun, 23 Jun 2019 13:10:39 +0000 Received: by mail-wr1-x444.google.com with SMTP id n4so9784965wrs.3 for ; Sun, 23 Jun 2019 06:10:36 -0700 (PDT) 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:user-agent; bh=aDghdSinIaiKsdOiETyKn+Z/DtxlZsP7t0csmmQV6Po=; b=SS8h9soKPQmoufNTUAigGqHQ77LeunNxMq2ZrpQA/474pCen0Vv9p/9wUHfhcmFIxF nw67sJokfKDOrSR48AihKnmPvpP7T4BT4ziS7YkbsOiz5LFddGt4ZIZBKU2+YqQ4DtCL N9gYIhoTxlS6/XgOoJwPMI6phjmQot7C4VhjQ568tZ4xyXg5y/GR0Du7GRjvbU40KfYI xmP5zDcp8FiKP4LaTbdBAAszw/mVh1MT1zT8+cp433+U/sQ1gEZSa/HaI4JoZhKHHTUW ibhdiAI7AOFq6SeOxl1wKLD88m7VkM5TtoluyyoLPxR4oXMPH5mqc36igtrjSZgt5mRW AKzg== 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:user-agent; bh=aDghdSinIaiKsdOiETyKn+Z/DtxlZsP7t0csmmQV6Po=; b=iWQDsIoieTONJOLXz/6ezu4g1AUIs1KDOGCFiM4OAD7rklizKMo0J8UwzBjR1fK24L 7phnQBDcN8+rwlfhQz9HdlM+7RlrdkXj8g2O8m9XGHghgAIC1JFpoRaJGk1erH7MORoI HwvK035NeZjUut+2mVQPOWZYXiXOb6FHKzIIp0W+3N5gnexuVHhohRqQxWBSZ7beWb3w 4Gep62a0FYTPyDFpQOnHXob8c2nTKViTpD8T8VeiiJDd+PC+/89cPHEBVhsplbXLoKMi 1BbcKZM4Xx2juK719GDJY4CxTCo5VvEHTtugSvgGGIIPwKy2V8p3mHw4PdotORFp0oe6 iaiA== X-Gm-Message-State: APjAAAW2pfbM2CrGk4HTtqPwCSxchAloADdU1ORENy587mP+7uPlUZyC xXycVvhOilgrE+t1cEQQnEetwA== X-Google-Smtp-Source: APXvYqwSZA0J30LwPynYWm71Zux0dC5J/g7VD3W/j4tNZIvMdgxAmuvkTU9AJJrs/Hk+sIgalxC7DA== X-Received: by 2002:a5d:4087:: with SMTP id o7mr92720866wrp.277.1561295433669; Sun, 23 Jun 2019 06:10:33 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id j4sm6485334wrx.57.2019.06.23.06.10.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 06:10:32 -0700 (PDT) Date: Sun, 23 Jun 2019 15:10:31 +0200 From: Tomas Vondra To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: David Rowley , Jesper Pedersen , Floris Van Nee , Rafia Sabih , Jeff Janes , Thomas Munro , Alexander Kuzmenkov , Peter Geoghegan , Thomas Munro , Bhushan Uparkar , PostgreSQL-development , Alexander Korotkov , James Coleman Subject: Re: Index Skip Scan Message-ID: <20190623131031.65zmz2m4waew6paa@development> References: <1559362223126.18661@Optiver.com> <988b7763-5c55-1be1-b7b6-f3a68eff0d40@redhat.com> <1559763453006.85615@Optiver.com> <1559763570329.85227@Optiver.com> <4d469bf2-49ff-bc3d-a428-6c7b5d87d526@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I've done some initial review on v20 - just reading through the code, no tests at this point. Here are my comments: 1) config.sgml I'm not sure why the enable_indexskipscan section says This parameter requires that enable_indexonlyscan is on. I suppose it's the same thing as for enable_indexscan, and we don't say anything like that for that GUC. 2) indices.sgml The new section is somewhat unclear and difficult to understand, I think it'd deserve a rewording. Also, I wonder if we really should link to the wiki page about FSM problems. We have a couple of wiki links in the sgml docs, but those seem more generic while this seems as a development page that might disapper. But more importantly, that wiki page does not say anything about "Loose Index scans" so is it even the right wiki page? 3) nbtsearch.c _bt_skip - comments are formatted incorrectly _bt_update_skip_scankeys - missing comment _bt_scankey_within_page - missing comment 4) explain.c There are duplicate blocks of code for IndexScan and IndexOnlyScan: if (indexscan->skipPrefixSize > 0) { if (es->format != EXPLAIN_FORMAT_TEXT) ExplainPropertyInteger("Distinct Prefix", NULL, indexscan->skipPrefixSize, es); } I suggest we wrap this into a function ExplainIndexSkipScanKeys() or something like that. Also, there's this: if (((IndexScan *) plan)->skipPrefixSize > 0) { ExplainPropertyText("Scan mode", "Skip scan", es); } That does not make much sense - there's just a single 'scan mode' value. So I suggest we do the same thing as for unique joins, i.e. ExplainPropertyBool("Skip Scan", (((IndexScan *) plan)->skipPrefixSize > 0), es); 5) nodeIndexOnlyScan.c In ExecInitIndexOnlyScan, we should initialize the ioss_ fields a bit later, with the existing ones. This is just cosmetic issue, though. 6) nodeIndexScan.c I wonder why we even add and initialize the ioss_ fields for IndexScan nodes, when the skip scans require index-only scans? 7) pathnode.c I wonder how much was the costing discussed. It seems to me the logic is fairly similar to ideas discussed in the incremental sort patch, and we've been discussing some weak points there. I'm not sure how much we need to consider those issues here. 8) execnodes.h The comment before IndexScanState mentions new field NumDistinctKeys, but there's no such field added to the struct. 9) pathnodes.h I don't understand what the uniq_distinct_pathkeys comment says :-( 10) plannodes.h The naming of the new field (skipPrefixSize) added to IndexScan and IndexOnlyScan is clearly inconsistent with the naming convention of the existing fields. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services