Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a3P3D-0003ok-7W for pgsql-performance@arkaria.postgresql.org; Mon, 30 Nov 2015 14:03:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a3P3C-0006ly-P0 for pgsql-performance@arkaria.postgresql.org; Mon, 30 Nov 2015 14:03:30 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1a3P3B-0006k6-PS for pgsql-performance@postgresql.org; Mon, 30 Nov 2015 14:03:30 +0000 Received: from nm21-vm9.bullet.mail.ir2.yahoo.com ([212.82.97.6]) by magus.postgresql.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a3P38-0002YN-Ja for pgsql-performance@postgresql.org; Mon, 30 Nov 2015 14:03:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1448892204; bh=VIU3xGEsfMHz/iObXz1Tt5zzGPBZ8Jdvq2Nrg490hRA=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=M3vhA+81qjpS7SresSAL3cKxr7UKJ/+7/XdoeNWjZY3zjPH4o5XKMBJbw24XA8+FbYuGYb4fl8e++KD1RwRSDJNbMjT8MFnlexL56X8+aeIyd0A7oz3IhQ0Qmz2eyePqZoTW38j9f5pT8A8aGp81SZ6JnrYgm7s01ml6+kGlzKniJnLDeaQruTG9nHoZeXDDkH5ZYFXnCapPtVTXkep6iCITrQwxxkIzfOuES+AM1sjMVGoEnGr53p5nYwlmBlSLGMbrHb+wq3U08CQWTDav9HP0qKXgxJHVn3gFZW03KYacgNLtLB3mexzzXOjiEGNzFvIsrrwZN1+QhFKGgperDg== Received: from [212.82.98.124] by nm21.bullet.mail.ir2.yahoo.com with NNFMP; 30 Nov 2015 14:03:24 -0000 Received: from [212.82.98.71] by tm17.bullet.mail.ir2.yahoo.com with NNFMP; 30 Nov 2015 14:03:24 -0000 Received: from [127.0.0.1] by omp1008.mail.ir2.yahoo.com with NNFMP; 30 Nov 2015 14:03:24 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 125276.49117.bm@omp1008.mail.ir2.yahoo.com X-YMail-OSG: 38kwJIIVM1lEnxuIq9HJhFof3VaYNH5FEcMuzpShb.zGAs6AwYMG8wwFHdiec3e TV0ooFdtck25IMYwt0UwyFvJbTYZnRI449eH7Ls1bwYjeG8gXt.qjrvnjGOFutZ301TtMBJlM8GL q5AbunATvBtPpXEgwrzjTmsElMzZiKXnasKAytjwME3IOoYMFqqOqiAGBcTUN9Ckow32umjfcnvI zyb4DjlxNZ40bBefQbAb6.TcNGTiDreh0lUNNijM8h00FqEeCF0T8tkd60BLha6ALaYPJDX_Qyac 5.Van8cr347obLQyQgWafbvuAttLlB6h7tmPUgBP8XcdeibwSlNDFqtq1TxYTfcH5gXa1T5r50F. obUQvP3O_yvfQxwbcHtfa5JSMnPCWDUoPm5UO61DVnMGWOTyV9dA.eYGCye02ooft7GqGLRNhxpA eV2zPVU1kTe_cboMbrWjxpDse5w34cW_RICOFS33QLCoAFj15qQSb5ttEKN7QLcsbuAcfTjWa.v8 HaWQAhWaXxeCsuFhu Received: by 212.82.98.119; Mon, 30 Nov 2015 14:03:23 +0000 Date: Mon, 30 Nov 2015 14:03:21 +0000 (UTC) From: Glyn Astill Reply-To: Glyn Astill To: Jeff Janes Cc: Pgsql-performance Message-ID: <1322503558.4427005.1448892201990.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: References: Subject: Re: Index scan cost calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 1964 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org > From: Jeff Janes > To: Glyn Astill > Cc: Pgsql-performance > Sent: Saturday, 28 November 2015, 19:25 > Subject: Re: [PERFORM] Index scan cost calculation > > > Why does the index seats_index02 exist in the first place? It looks > like an index designed for the benefit of a single query. In which > case, could flag column be moved up front? That should prevent it > from looking falsely enticing. > > A column named "flag" is not usually the type of thing you expect to > see a range query on, so moving it leftward in the index should not be > a problem. > Unfortunately it's not possible to move flag left in this scenario. As you say it's an issue that would not really exist in normal SQL access. The main issue is the way it's required for ordering; The index in question is used by a legacy language that accesses records sequentially as if they were direct from isam files it used historically via a driver. In some cases it steps through records on a particular show+type until a flag changes and carries on unless particular values are seen. If I create the index show+best+block+row+seat then the planner appears to favour that, and all is well. Despite the startup cost estimate being the same, and total cost being 0.01 higher. This is something I fail to understand fully. Tom stated the index choice is due to a selectivity underestimate. I think this may be because there is actually a correlation between "best"+"block" and "type", but from Toms reply my understanding was that total selectivity for the query is calculated as the product of the individual selectivities in the where clause. Are particular equality clauses ever excluded from the calculation as a result of available indexes or otherwise? Or is it just likely that the selection of the new index is just by chance? Either way I my understanding here is definitely lacking. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance