Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a4Tfl-0007fH-SM for pgsql-performance@arkaria.postgresql.org; Thu, 03 Dec 2015 13:11:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a4Tfl-0005ro-F4 for pgsql-performance@arkaria.postgresql.org; Thu, 03 Dec 2015 13:11:45 +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 1a4Te7-0003PB-FN for pgsql-performance@postgresql.org; Thu, 03 Dec 2015 13:10:03 +0000 Received: from nm42-vm8.bullet.mail.gq1.yahoo.com ([67.195.87.159]) by magus.postgresql.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a4Te4-0000OK-0P for pgsql-performance@postgresql.org; Thu, 03 Dec 2015 13:10:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1449148196; bh=VFfFc8Xua0Mcv1w6O5apvAGvIspLqINT4r3URmgcUJo=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=MAG0V9wC0ykzQ3MzI+MbCu6Jw7Txrp5sqLvTlzhQuYPjSzICzXmF+75plLvQCzFhcPH4VYROvnwGyC2m/ZIGmRztLyyEyysgUZusd7IFdxaw95HLTC5vzXWe8tuNVxMPQIiFqXrjZ4OrCdAadlXF+s6kC5IjlBIVfhJTyU8fJEpFH+zWc05o8Bzt6MSG6Q6oUJUCQCGEACh/UZC3otNDEy6ORp+hd5rbGRAD/QUqxbgPKPI+A/bxBhr1RUYdxyQjhRHjwix2yL2jCaAYgfIn39pMnMp88NWAzJodJC7PNuOsg8AwUzt9O33+Sf19aiTUyX5iOsesEmi2lwSHE/5h0w== Received: from [127.0.0.1] by nm42.bullet.mail.gq1.yahoo.com with NNFMP; 03 Dec 2015 13:09:56 -0000 Received: from [98.137.12.59] by nm42.bullet.mail.gq1.yahoo.com with NNFMP; 03 Dec 2015 13:06:59 -0000 Received: from [212.82.98.61] by tm4.bullet.mail.gq1.yahoo.com with NNFMP; 03 Dec 2015 13:06:59 -0000 Received: from [212.82.98.89] by tm14.bullet.mail.ir2.yahoo.com with NNFMP; 03 Dec 2015 13:06:59 -0000 Received: from [127.0.0.1] by omp1026.mail.ir2.yahoo.com with NNFMP; 03 Dec 2015 13:06:59 -0000 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 223428.99193.bm@omp1026.mail.ir2.yahoo.com X-YMail-OSG: bG8BmIAVRDs0Ozlu.p6lsoEVVvbKi5WpunrvYPFNgTAYaDg- Received: by 212.82.98.123; Thu, 03 Dec 2015 13:06:58 +0000 Date: Thu, 3 Dec 2015 13:06:57 +0000 (UTC) From: Glyn Astill Reply-To: Glyn Astill To: Jim Nasby , Jeff Janes Cc: Pgsql-performance Message-ID: <1409411790.24325018.1449148017669.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: <565F718B.7080802@BlueTreble.com> References: <565F718B.7080802@BlueTreble.com> Subject: Re: Index scan cost calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 1732 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: Jim Nasby >To: Jeff Janes ; Glyn Astill >Cc: Pgsql-performance >Sent: Wednesday, 2 December 2015, 22:32 >Subject: Re: [PERFORM] Index scan cost calculation > > >On 11/30/15 5:03 PM, Jeff Janes wrote: >> It thinks the combination of (show, type, best, block) is enough to >> get down to a single row. One index adds "flag" to that (which is not >> useful to the query) and the other adds "row" to that, which is useful >> but the planner doesn't think it is because once you are down to a >> single tuple additional selectivity doesn't help. > >It occurs to me that maybe you could force this behavior by building an >index on a row() instead of on the individual fields. IE: > >CREATE INDEX ... ON( row(show, type, best, block, row) ) > >You would then have to query based on that: > >WHERE row(show, type, best, block, row) = row( 'Trans Siberian >Orchestra', 'Music', true, 1, 1 ) > >You mentioned legacy code which presumably you can't modify to do that, >but maybe there's a way to trick the planner into it with a view... > >CREATE VIEW AS >SELECT r.show, r.type, r..., etc, etc > FROM ( SELECT *, row(show, type, best, block, row) AS r FROM table ) a >; > >When you stick a where clause on that there's a chance it'd get turned >into WHERE row() = row()... but now that I see it I'm probably being >over optimistic about that. You could probably force the issue with an >ON SELECT ON table DO INSTEAD rule, but IIRC those aren't supported. Thanks, interesting idea, but no cigar. For the moment just ensuring the seats_index01 is the last index created seems to suffice, fragile though it is. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance