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 1hfVRr-00045x-J6 for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jun 2019 20:20:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hfVRq-0005dr-Ck for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jun 2019 20:20:18 +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 1hfVRq-0005dk-10 for pgsql-hackers@lists.postgresql.org; Mon, 24 Jun 2019 20:20:18 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfVRn-0005LN-8d for pgsql-hackers@lists.postgresql.org; Mon, 24 Jun 2019 20:20:16 +0000 Received: by mail-wr1-x443.google.com with SMTP id p11so15261765wre.7 for ; Mon, 24 Jun 2019 13:20:15 -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=UMygAiCBB9AtmZsOtYL9Yc9e0d/0nWG9o5ehrbKwteQ=; b=QSQOjLfwEq+jUgKg171oU3Bc5uI0RRSo3KxmbfXk5BP5T1GLAJ+dpH2SQ4Nf0y9SY0 /OI1/3A/MUa2lQjhfHGWV091TAQqVsxtYnK2t9DDYjionPEs1s5QUA3/MP11Q5/tDLlU sDttSb2wlpVbGqU7+JIyPzE5PNGjqpHdm0eg5FWpBv8VkmbxR6l5nxI5E7I3ZCkPfA6j eUPaWrAsnDFZBbYFF0f4toEplq1AVjNcw0LrVV1OLZ3PeuiUvVcLBIlFDIq69aIMz/VP ziDqOozhXb+f8uFI+jfOIBvrVUsqLUmlVgBS5Nb7fvgW1tndCtqyLszLownFIF6Y/gJ/ jIhg== 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=UMygAiCBB9AtmZsOtYL9Yc9e0d/0nWG9o5ehrbKwteQ=; b=X0geTKzp9g6tcxgOLcEU+6n6cHMG6HOOohCZo6y36AjEuuhu4QqdG7+HvRSrS0/S0a v+oS8ICgTIYos4Mzw3Q+r8bRYBOW+AuVmqfsm4O+CHenUurChBkq71+Efygn40gKlvTX rtunOVt7No7ZsSn+lA5M0qvtwS9y4heUGrAggUdl6CxABglKR0GLlTROqKLcQS316zjj mMM24+zuboikT7U4JM07AfCM+Mb+i/eSabZgc+aLN/gWkfFn+nnC8D3aRNmzhBfwHFb8 ImG7HHipSvswFJznLl+KpdymDuBW20FxcXGUxmqTs0I0yYBcsCnrsfJQEuzwtodKKjAT f5fg== X-Gm-Message-State: APjAAAX+hPd/PflkISDc1SWfQaeCR4E99D/anQyHJ++uQ/RXcLIfD+cm WJBt641Fyc9uxZcKjaWQQPm4pA== X-Google-Smtp-Source: APXvYqwm9LEIW6So2AulYmn9X2IgUKpSxxOr3bV1OjROJ9B1YuOtgQWoLW33rFt3dCoy+ynu8csWxg== X-Received: by 2002:a5d:620f:: with SMTP id y15mr32426047wru.262.1561407613147; Mon, 24 Jun 2019 13:20:13 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id v27sm28308119wrv.45.2019.06.24.13.20.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 13:20:12 -0700 (PDT) Date: Mon, 24 Jun 2019 22:20:10 +0200 From: Tomas Vondra To: Simon Riggs Cc: James Coleman , Rafia Sabih , Shaun Thomas , Dmitry Dolgov <9erthalion6@gmail.com>, Alexander Korotkov , Tom Lane , PostgreSQL Developers Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort) Message-ID: <20190624202010.7n7lolmrcs67udcg@development> References: <20190602211753.rxor4apm7zfiltt3@development> <20190614181135.tdj7aq4iffy5ghl2@development> 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 On Mon, Jun 24, 2019 at 07:05:24PM +0100, Simon Riggs wrote: >On Mon, 24 Jun 2019 at 18:01, James Coleman wrote: > >> On Mon, Jun 24, 2019 at 12:56 PM Simon Riggs >> wrote: >> >> > What is the specific use case for this? This sounds quite general case. >> >> They are both general cases in some sense, but the concerns lie mostly >> with what happens when they're unexpectedly encountered. For example, >> if the expected row count or group size is off by a good bit and we >> effectively have to perform a sort of all (or most) possible rows. >> >> If we can get the performance to a point where that misestimated row >> count or group size doesn't much matter, then ISTM including the patch >> becomes a much more obvious total win. >> > >I was trying to think of ways of using external information/circumstance to >knowingly avoid negative use cases. i.e. don't treat sort as a black box, >use its context. > Like what, for example? I'm not saying there's no such additional information, but I can't think of anything at the moment. One of the issues is that while the decision whether to use incremental sort is done during planning, most of the additional (and reliable) infomation about the data is only available at execution time. And it's likely not available explicitly - we need to deduce it. Which I think is exactly what the min group size heuristics is about, no? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services