Return-Path: X-Original-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F699113EE for ; Wed, 6 Aug 2014 14:24:24 +0000 (UTC) Received: (qmail 83406 invoked by uid 500); 6 Aug 2014 14:24:20 -0000 Delivered-To: apmail-hadoop-hdfs-user-archive@hadoop.apache.org Received: (qmail 83280 invoked by uid 500); 6 Aug 2014 14:24:19 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 83265 invoked by uid 99); 6 Aug 2014 14:24:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 14:24:19 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sergeymurylev@gmail.com designates 209.85.213.48 as permitted sender) Received: from [209.85.213.48] (HELO mail-yh0-f48.google.com) (209.85.213.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 14:24:15 +0000 Received: by mail-yh0-f48.google.com with SMTP id i57so1774120yha.35 for ; Wed, 06 Aug 2014 07:23:54 -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 :content-type; bh=OSYgSqH5RpHOtVNMGIwH06HcsC0W86gvDJaGna/Sxak=; b=mUuY+kBCHpuCpSQdNm9VqI0+ipWtvJ2W4IBztbqI/hJ/dEpGaX0pcB5VFXuYHW2uQZ NWbMRetiBRD4Sn5bdqp5wMd5KMnkIr1+m6cDRjmUYYkAajYZIBR4yowtfb6vh3GWjz4a /bj3yRj+D2GVr+iqboKgZfsW3pXuMjtm2TlWInpFER9K7QWJMYeXqCm9UTWJ0fhtmjU/ gXnUjJFWOwpshZiVqClub+ORB5P0Fr3iBV9RwhriL2JvrUP4eFcqI3I75DUK6G0u2oD0 K2flOuXo9mEClzrP64bu5qdSqbU601+NkClCoRb/0M327rkvcKtecesNZKMPQzkrL8zr T3fQ== MIME-Version: 1.0 X-Received: by 10.236.79.230 with SMTP id i66mr17822278yhe.136.1407335034590; Wed, 06 Aug 2014 07:23:54 -0700 (PDT) Received: by 10.170.209.201 with HTTP; Wed, 6 Aug 2014 07:23:54 -0700 (PDT) Received: by 10.170.209.201 with HTTP; Wed, 6 Aug 2014 07:23:54 -0700 (PDT) In-Reply-To: References: Date: Wed, 6 Aug 2014 18:23:54 +0400 Message-ID: Subject: Re: High performance Count Distinct - NO Error From: Sergey Murylev To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=20cf30050c58d11e0904fff6b856 X-Virus-Checked: Checked by ClamAV on apache.org --20cf30050c58d11e0904fff6b856 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Why do you think that default implementation of COUNT DISTINCT is slow? As far as I understand the most famous way to find number of distinct elements is to sort them and scan all sorted items consequently excluding duplicated elements. Assimptotics of this algoritm is O(n *log n ), I think that there is no way to do this faster in general case. I think that Hive should use map-reduce sort stage to make items sorted, but probably in your case we have only one reduce task because we need to aggregate result on single instance. 06 =D0=B0=D0=B2=D0=B3. 2014 =D0=B3. 12:54 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0= =BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C "Natarajan, Prabakaran 1. (NSN - IN/Bangalore)" =D0=BD=D0=B0=D0=BF=D0=B8=D1= =81=D0=B0=D0=BB: > > Hi > > I am looking for high performance count distinct solution on Hive Query. > > Regular count distinct is very slow but if I use probabilistic count distinct has more error percentage (if the number of records are small). > > > Is there is any solution to have exact count distinct but using low memory and without error? > > Thanks and Regards > Prabakaran.N > > > --20cf30050c58d11e0904fff6b856 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Why do you think that default implementation of COUNT DISTIN= CT is slow? As far as I understand the most famous way to find number of di= stinct elements is to sort them and scan all sorted items consequently excl= uding duplicated elements. Assimptotics of this algoritm is O(n *log n ), I= think that there is no way to do this faster in general case. I think that= Hive should use map-reduce sort stage to make items sorted, but probably i= n your case we have only one reduce task because we need to aggregate resul= t on single instance.
06 =D0=B0=D0=B2=D0=B3. 2014 =D0=B3. 12:54 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0= =BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C "Natarajan, Prabakaran 1. (NSN= - IN/Bangalore)" <prabakaran.1.natarajan@nsn.com> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0= =B0=D0=BB:
>
> Hi
> =C2=A0
> I am looking for high performance count distinct solution on Hive Quer= y.
> =C2=A0
> Regular count distinct is very slow but if I use probabilistic count d= istinct has more error percentage (if the number of records are small).
> =C2=A0
> =C2=A0
> Is there is any solution to have exact count distinct but using low me= mory and without error?
> =C2=A0
> Thanks and Regards
> Prabakaran.N=C2=A0 =C2=A0
> =C2=A0
> =C2=A0
> =C2=A0

--20cf30050c58d11e0904fff6b856--