Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id BAFDE1EB83EA for ; Thu, 23 Feb 2012 12:56:41 -0400 (AST) Received: from smtp.optionshouse.com ([38.98.137.6] helo=smtp.peak6.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S0by9-0002Af-Si for pgsql-performance@postgresql.org; Thu, 23 Feb 2012 16:56:40 +0000 X-AuditID: 0a64cb1e-b7b86ae000000b8b-f5-4f466f3edbb2 Message-ID: <4F466FB6.8070609@peak6.com> Date: Thu, 23 Feb 2012 10:56:22 -0600 From: Shaun Thomas Reply-To: Organization: Peak6 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Venkat Balaji CC: PGSQL Performance Subject: Re: : Cost calculation for EXPLAIN output References: In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.107.46] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsXCxcQroWuf7+Zv8HY1p8X1meeYLRY9Xsvi wORxYd80do9JD6awBTBFNTDaJObl5ZcklqQqpKQWJ9sqBbg6epspuGQWJ+ckZuamFikpZKbY KpkpKRTkJCan5qbmldgqJRYUpOalKNlxKWAAG6CyzDyF1Lzk/JTMvHRbJc9gf10LC1NLXUMl u3gsIKGJJeNBwxeWgpWcFcdf3GZuYNzM3sXIySEhYCIxf/UlRghbTOLCvfVsIDavgIZEz6Lp YDUsAqoSc0/2gcXZBNQkFu6+CVYvJCArsX/VOVYQm19AWGLfhybmLkYODlGBMIkF7zwhxghK nJz5hAXEFhHQkjhy9DJYK7OAhcTfSx/BbGEBG4nOuS9ZIEYGSMyYfRdsFadAoMTcC5/ZIept JS7Muc4CYctLbH87hxmiXk7iTsNzNojzFSTmXG1nmcAoNAvJ6llI2mchaV/AyLyKUby4LDE5 I9O0oDi3pMBQryA1MdtMLy+1ZBMjKG5TTsvtYJy+VPEQowAHoxIPL7Ogq78Qa2JZcWXuIUYJ DmYlEd7Ljm7+QrwpiZVVqUX58UWlOanFhxhNgUE2kVlKNDkfmFLySuINjQ0tTS2NzQyMTCwt lMR5OXls/YUE0oGpITs1tSC1CKaPiYNTqoFxgd6qSofXWTaCLl3l+xolPFcsdDlxfsou3kfG Zeu0/9i47Pi0/ktd8JkeFquW07yhl8LS/vwsLt0168nB1vuaBkbepsF1nG5xioa8c8U7ljpE /FshZJTi5KF++NgdtfCtG3JNVl0oS7ult2lHydvLQjZtm2b2Or77oL2Ne5bdREOJ0in6KXpK LMUZiYZazEXFiQDIwJHZ8QIAAA== X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/167 X-Sequence-Number: 46339 On 02/23/2012 06:21 AM, Venkat Balaji wrote: > The cost is "13.88" to fetch 1 row by scanning an Primary Key > indexed column. > > Isn't the cost for fetching 1 row is too high ? Not really. The "cost" is really just an estimate to rank alternate query plans so the database picks the least expensive plan. The number '13.88' is basically meaningless. It doesn't translate to any real-world equivalent. What you actually care about is the execution time. If it takes 0.25ms or something per row, that's what really matters. For what it's worth, it looks like you have the right query plan, there. Scan the primary key for one row. What's wrong with that? Our systems have tables far larger than yours, handling 300M queries per day that are far more expensive than a simple primary key index scan. You'll be fine. :) I suggest you set log_min_duration_statement to something like 1000, to send any query that takes longer than 1 second to the PG logs. Concentrate on those queries, because ones like this are already working right. -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604 312-444-8534 sthomas@peak6.com ______________________________________________ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email