Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8A13DB5DC5E for ; Thu, 22 Sep 2011 10:55:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 40110-07 for ; Thu, 22 Sep 2011 13:55:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-yi0-f46.google.com (mail-yi0-f46.google.com [209.85.218.46]) by mail.postgresql.org (Postfix) with ESMTP id 716CDB5DC09 for ; Thu, 22 Sep 2011 10:55:17 -0300 (ADT) Received: by yib18 with SMTP id 18so1886430yib.19 for ; Thu, 22 Sep 2011 06:55:17 -0700 (PDT) Received: by 10.236.77.233 with SMTP id d69mr13504907yhe.84.1316699716935; Thu, 22 Sep 2011 06:55:16 -0700 (PDT) Received: from [192.168.0.3] (ip98-169-137-173.dc.dc.cox.net. [98.169.137.173]) by mx.google.com with ESMTPS id f24sm31061196ann.5.2011.09.22.06.55.16 (version=SSLv3 cipher=OTHER); Thu, 22 Sep 2011 06:55:16 -0700 (PDT) Message-ID: <4E7B3E50.2070608@getcarbonblack.com> Date: Thu, 22 Sep 2011 09:55:28 -0400 From: Michael Viscuso User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: "ktm@rice.edu" CC: Tom Lane , Greg Smith , pgsql-performance@postgresql.org Subject: Re: Query optimization using order by and limit References: <4E7A93F9.1050301@2ndQuadrant.com> <6768.1316657361@sss.pgh.pa.us> <4E7AA399.6000209@getcarbonblack.com> <7868.1316661773@sss.pgh.pa.us> <20110922134125.GJ30871@staff-mud-56-27.rice.edu> In-Reply-To: <20110922134125.GJ30871@staff-mud-56-27.rice.edu> X-Enigmail-Version: 1.3.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/345 X-Sequence-Number: 45121 Thanks Ken, I'm discussing with my coworker how to best make that change *as we speak*. Do you think this will also resolve the original issue I'm seeing where the query doesn't "limit out properly" and spends time in child tables that won't yield any results? I was hoping that by using the check constraints, I could query over a week or month's worth of partitioned tables and the combination of order by and limit would eliminate any time searching unnecessary tables but that doesn't appear to be true. (I'm still very new to high-end Postgres performance so I could be mistaken.) Regardless, in the meantime, I'll switch those columns to bigint instead of numeric and have an update as soon as possible. Thanks for your help! Mike On 9/22/2011 9:41 AM, ktm@rice.edu wrote: > On Wed, Sep 21, 2011 at 11:22:53PM -0400, Tom Lane wrote: >> Michael Viscuso writes: >>> Greg/Tom, you are correct, these columns should be modified to whatever >>> is easiest for Postgres to recognize 64-bit unsigned integers. Would >>> you still recommend bigint for unsigned integers? I likely read the >>> wrong documentation that suggested bigint for signed 64-bit integers and >>> numeric(20) for unsigned 64-bit integers. >> Unsigned? Oh, hm, that's a bit of a problem because we don't have any >> unsigned types. If you really need to go to 2^64 and not 2^63 then >> you're stuck with numeric ... but that last bit is costing ya a lot. >> >> regards, tom lane >> > Hi Michael, > > If you have access to the application, you can map the unsigned 64-bits > to the PostgreSQL signed 64-bit type with a simple subtraction. That will > allow you to drop all the numeric use. Also if the guid is a 64-bit > values stuffed into a numeric(20), you can do it there as well. I achieved > a hefty performance boost by making those application level changes in a > similar situation. > > Regards, > Ken