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 1hlCMt-0006aX-Rs for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 13:10:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlCMs-0003g6-NA for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 13:10:42 +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 ) id 1hlCMs-0003XS-BM for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 13:10:42 +0000 Received: from mail-qt1-f171.google.com ([209.85.160.171]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlCMp-00043k-I4 for pgsql-hackers@postgresql.org; Wed, 10 Jul 2019 13:10:41 +0000 Received: by mail-qt1-f171.google.com with SMTP id a15so2292225qtn.7 for ; Wed, 10 Jul 2019 06:10:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=j7iTlAdhkgSgA43Q+mW/94CUmHyIUSvmyAmB3NygZkc=; b=lWLUNlcRRw8j+QVDVEJe4STaXpGZw2j6uX9bcXwx7AWlhxtHuxgeXUs4dBaRjdUjEZ cT116hyCa01RvN3CjncCTiuhVOqGnk8FiH0AtZubWzAH0R5rBzN0vtCCqoA6uTba15hA Zl3Vc6SHPA9qidyA+l1lPOuWyMH4wUXBtVrXh7le2Rra2OQ7b0chur746fsghbLqrZtW GXa1Rysmuw2nMC0xCooO0CO/7qIHQOCmKHxvpWXWdKY8sjTZnNStnTrmzt6kJSizxSan uTcu+zIybH9FUUFCJASpdOzhJjEcRgIyctzShSFLh7MEc7MNH7FuHad/PVR4R3R30r5g uT6w== X-Gm-Message-State: APjAAAXeXRMlf2q0hv/l9Ew428mgOXN3wjouBR5xpqbQo6a3WDZnjKZC nJ9qkCoh9JCYw2Es09HVBS2uVA== X-Google-Smtp-Source: APXvYqwNoYzTtjPuCfI8PkdkTY52yycczpE6fEU7x/EfN66kJK/XRuJ3VgN22ztcDZ5li+VFwHCYSg== X-Received: by 2002:ac8:5547:: with SMTP id o7mr11104054qtr.297.1562764238115; Wed, 10 Jul 2019 06:10:38 -0700 (PDT) Received: from localhost.localdomain (c-24-61-8-151.hsd1.ma.comcast.net. [24.61.8.151]) by smtp.gmail.com with ESMTPSA id r36sm1096576qte.71.2019.07.10.06.10.36 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jul 2019 06:10:37 -0700 (PDT) Reply-To: jesper.pedersen@redhat.com Subject: Re: Index Skip Scan To: Thomas Munro Cc: David Rowley , Dmitry Dolgov <9erthalion6@gmail.com>, Floris Van Nee , James Coleman , Rafia Sabih , Jeff Janes , Peter Geoghegan , Tomas Vondra , Thomas Munro , Bhushan Uparkar , PostgreSQL-development , Alexander Korotkov References: <2685f020-f302-9bf6-1b5c-ebc2bcebc635@2ndquadrant.com> <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> <3e5f8a7d-67a4-46c8-e113-0a7e2dad2db6@redhat.com> From: Jesper Pedersen Organization: Red Hat Message-ID: Date: Wed, 10 Jul 2019 09:10:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 7/9/19 10:14 PM, Thomas Munro wrote: >> Thomas, do you have any ideas for this ? I can see that MySQL did the >> functionality in two change sets (base and function support), but like >> you said we shouldn't paint ourselves into a corner. > > I think amskip() could be augmented by later patches to take a > parameter 'skip mode' that can take values SKIP_FIRST, SKIP_LAST and > SKIP_FIRST | SKIP_LAST (meaning please give me both). What we have in > the current patch is SKIP_FIRST behaviour. Being able to choose > SKIP_FIRST or SKIP_LAST allows you do handle i, MAX(j) GROUP BY (i) > ORDER BY i (ie forward scan for the order, but wanting the highest key > for each distinct prefix), and being able to choose both allows for i, > MIN(j), MAX(j) GROUP BY i. Earlier I thought that this scheme that > allows you to ask for both might be incompatible with David's > suggestion of tracking UniqueKeys in paths, but now I see that it > isn't: it's just that SKIP_FIRST | SKIP_LAST would have no UniqueKeys > and therefore require a regular agg on top. I suspect that's OK: this > min/max transformation stuff is highly specialised and can have > whatever magic path-building logic is required in > preprocess_minmax_aggregates(). > Ok, great. Thanks for your feedback ! Best regards, Jesper