Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U90wK-0006Lm-J6 for pgsql-performance@arkaria.postgresql.org; Fri, 22 Feb 2013 22:18:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U90wJ-0007iY-Tc for pgsql-performance@arkaria.postgresql.org; Fri, 22 Feb 2013 22:17:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U90wI-0007iT-S2 for pgsql-performance@postgresql.org; Fri, 22 Feb 2013 22:17:58 +0000 Received: from nm27-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.139]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U90wF-0006Ov-NI for pgsql-performance@postgresql.org; Fri, 22 Feb 2013 22:17:58 +0000 Received: from [98.139.212.148] by nm27.bullet.mail.bf1.yahoo.com with NNFMP; 22 Feb 2013 22:17:54 -0000 Received: from [98.139.212.244] by tm5.bullet.mail.bf1.yahoo.com with NNFMP; 22 Feb 2013 22:17:54 -0000 Received: from [127.0.0.1] by omp1053.mail.bf1.yahoo.com with NNFMP; 22 Feb 2013 22:17:54 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 649177.74085.bm@omp1053.mail.bf1.yahoo.com Received: (qmail 52077 invoked by uid 60001); 22 Feb 2013 22:17:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1361571474; bh=nT7g1n9lEGYevx8vtCxX5a7Sd/x2ZOa7PsnIv+AUaog=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=5xiUAftKkZhN1jJwy00TV7SMDWTqGv/kNSJ8iltDbXGPEyFLqb/yMm1//Soc5f/xR3eKn82ftFHwK8ZsEU1bjrXqThL5nizOeAnEdwK8VZBbf4V5L57BkQWl1IbvNl21sPRes8pQvjFXkFRd8znZLAFtAyp0d3HSz27sYVbC/Wg= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=JcoZ2KsodkqmG3PezFSgVuCa3EFXbIMdWJPIv+hWs3X1DLD36+F1aP8cKQ/d/kZ8iDzk6yy/y6Kiio5Fgm7AFCTclGoZc2yt0ofEQahwlxbnMCvv/fflD9m7Wm2ITcwPsAI6Cb3gfcGu/MKbLWA5a5ptq7Y/gDflAtWSUd3c6vU=; X-YMail-OSG: IcLbKawVM1kosmA2HHCLp0s5ShRN4oXN2wxJDiVy0aYaEEA J5E8tCRSylfotfB6ofIR8O4IpiKD9xyZPBAZgb5HHtRcV1p.nNHJIoHFFkdI 8b1tWw8iAjDOiLENJURAJ1ifl8KFdvgTGbCejC.T5kXdVoXLM1OZdGkAWeOx B5zQhS_3BXFZ0RlyZxWI7.L8xG69m4FOAlIHSsWzxFYig2M3zlyLnep7Ll98 5kvhzleWZadCiPjDiLCr4QA1OsDdPEtZGmPW4.3ovHwBm8.sYPhIiNFoj5WJ JSDunyc6U5Fj1XkXO4vw.ddaoqlam0m9iDkEVR3Ucf4E.llNcpwuHHOeOPZ9 Vh6ibNaURYnHa9pR1EX0d5fSg6BPJ575ih8HYLgWqA0lzIcsBo56WTiWZoBV MB4TWw1QTiX1lLbLajyoeP07h7iPqsi.vEx7ZTaruEAl9VejybQuIOeVGyx3 7eqFv2J6Z0cYwsrCW5fxrAYfRmeKKyauNBlkv4EF1fk0ISJWHk8pzNLHfeJp e1CTk1IBS6o5KK.k_fIV3846mODs2qPhAcGMB.UI- Received: from [76.255.18.237] by web162901.mail.bf1.yahoo.com via HTTP; Fri, 22 Feb 2013 14:17:54 PST X-Rocket-MIMEInfo: 001.001, QWxleGFuZGVyIFN0YXVibyA8YWxleEBiZW5nbGVyLm5vPiB3cm90ZToKPiBPbiBGcmlkYXksIEZlYnJ1YXJ5IDIyLCAyMDEzIGF0IDIxOjQ3ICwgS2V2aW4gR3JpdHRuZXIgd3JvdGU6Cgo.PiBJbiBteSBleHBlcmllbmNlIHRoZXNlIHByb2JsZW1zIGNvbWUgbGFyZ2VseSBmcm9tIHRoZSBwbGFubmVyCj4.IG5vdCBrbm93aW5nIHRoZSBjb3N0IG9mIGRlYWxpbmcgd2l0aCBlYWNoIHR1cGxlLiBJIHNlZSBhIGxvdAo.PiBsZXNzIG9mIHRoaXMgaWYgSSByYWlzZSBjcHVfdHVwbGVfY29zdCB0byBzb21ldGhpbmcBMAEBAQE- X-Mailer: YahooMailWebService/0.8.134.513 References: <19B2B4ECC4724A438200C54257BA8B20@gmail.com> <1361566076.10158.YahooMailNeo@web162905.mail.bf1.yahoo.com> Message-ID: <1361571474.31440.YahooMailNeo@web162901.mail.bf1.yahoo.com> Date: Fri, 22 Feb 2013 14:17:54 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: Bad query plan with high-cardinality column To: Alexander Staubo Cc: "pgsql-performance@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) 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 Alexander Staubo wrote: > On Friday, February 22, 2013 at 21:47 , Kevin Grittner wrote: >> In my experience these problems come largely from the planner >> not knowing the cost of dealing with each tuple. I see a lot >> less of this if I raise cpu_tuple_cost to something in the 0.03 >> to 0.05 range. > > Is this something I can just frob a bit without worrying about it > adversely impacting database performance across the board, or > should I be very careful and do lots of testing on a staging box > first? If possible, I would recommend trying it with the old indexes and seeing whether it causes it to choose the better plan.=A0 (Of course, you're not going to beat the plan you get with the two-column index for this query, but it might help it better cost the other alternatives, which would be a clue that it makes your overall costing model more accurate and would have a more general benefit.) You can play with settings like this in a single session without affecting any other sessions. I always recommend testing a change like this in staging and closely monitoring after deploying to production, to confirm the overall benefit and look for any odd cases which might suffer a performance regression.=A0 For this particular change, I have never seen a negative effect, but I'm sure that it's possible to have a scenario where it isn't helpful. Personally, I have changed this setting many times and have often noted that 0.02 was not enough to cause choice of an optimal plan, 0.03 was always enough to do it if adjusting this setting was going to help at all, and boosting it to 0.05 never caused further plan changes in the cases I tested.=A0 I have never seen such increases cause less optimal plan choice. If you try this, please post your results. -- Kevin Grittner EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance