Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOtHO-00073V-SW for pgsql-performance@arkaria.postgresql.org; Wed, 25 Sep 2013 17:53:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VOtHN-0005D2-Co for pgsql-performance@arkaria.postgresql.org; Wed, 25 Sep 2013 17:53:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOtHD-0004zx-LN for pgsql-performance@postgresql.org; Wed, 25 Sep 2013 17:53:27 +0000 Received: from mail-pd0-x234.google.com ([2607:f8b0:400e:c02::234]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VOtH6-0005ek-Oo for pgsql-performance@postgresql.org; Wed, 25 Sep 2013 17:53:27 +0000 Received: by mail-pd0-f180.google.com with SMTP id y10so2125pdj.39 for ; Wed, 25 Sep 2013 10:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=f1wlC2fg92H2NQM2bwdcX5N+Yds6Gm8QTT96crJM3kE=; b=ZJQygZCvkj1Nd3gN8w9RKTeHt171NLKbqkIWbKewSZOffw0UQFECGKqPgglJTIeoTL 3SRW9VmrQQuig3VOLwdeN3PnUefx01jgSN+i+mOQ3NTHNu8OCTsUUSSgaM2HgFKYUC9Z pFG2oKJy+v6v/zu2pFnc2yHMcK3YsFod6K4IMNkv4WwnpnMKFZ/msB4dgzQABfgKjOAT FGuRAAWZHPbh7NohBYpDW63rnwIJVXeFES1Cg6pg/1aM3POFKI4bn+aeKgjaBSb31vEE vZ/JonqlGmvSF+YaI0N5YBdfz2EgNCvV80PWTQb9h1CKzRo3ZLUAJ9jM3khgfivf0nlb /8qQ== MIME-Version: 1.0 X-Received: by 10.66.163.164 with SMTP id yj4mr447950pab.91.1380131597639; Wed, 25 Sep 2013 10:53:17 -0700 (PDT) Received: by 10.68.52.197 with HTTP; Wed, 25 Sep 2013 10:53:17 -0700 (PDT) In-Reply-To: <523B62CF.5080502@agliodbs.com> References: <523B62CF.5080502@agliodbs.com> Date: Wed, 25 Sep 2013 10:53:17 -0700 Message-ID: Subject: Re: Why is n_distinct always -1 for range types? From: Peter Geoghegan To: Josh Berkus Cc: postgres performance list Content-Type: text/plain; charset=ISO-8859-1 X-Pg-Spam-Score: -1.8 (-) 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 On Thu, Sep 19, 2013 at 1:47 PM, Josh Berkus wrote: > 4. n-distinct will still be listed as -1 (unique) for the column. > > Why? Because of this: https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/rangetypes_typanalyze.c#L205 We only collect and use histograms of lower and upper bounds for range types, and the fraction of empty ranges. -- Regards, Peter Geoghegan -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance