Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4zyl-0006UA-8e for pgsql-general@arkaria.postgresql.org; Wed, 26 Sep 2018 02:55:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4zyf-00083S-QA for pgsql-general@arkaria.postgresql.org; Wed, 26 Sep 2018 02:55:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4zyf-000838-DP for pgsql-general@lists.postgresql.org; Wed, 26 Sep 2018 02:55:01 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4zyc-0005Ig-OS for pgsql-general@lists.postgresql.org; Wed, 26 Sep 2018 02:55:00 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id E5F7D21C2964 for ; Wed, 26 Sep 2018 05:54:56 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from mail.postgrespro.ru (cyclops.l.postgrespro.ru [192.168.27.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id B5A9621C295F for ; Wed, 26 Sep 2018 05:54:56 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1537930496; bh=RplB8/DumpZwHZvWspvm8A0HRCRtpUB+Mbu1if3ddLg=; h=Date:From:To:Subject; b=R2GN7eXlU6lz+HslGF9f8CMUY4erhx+8NsGl0BVxbhIyT9FjqylZ+ztMP+ITHH+Jc b5tUWvuyn/whn839XJkBQemUmyKuvS6o5JW613Nt01goVwoDjPscGx7NmFijnBHGYO 2QGrkHXWp0ms5gKywaAHPouQZCW9vR43/5Yx9oCg= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 26 Sep 2018 09:54:56 +0700 From: r.zharkov@postgrespro.ru To: "pgsql-generallists.postgresql.org" Subject: Strange behavior of the random() function Message-ID: <00b2388c8e5a8d1dfb693d2b59b00722@postgrespro.ru> X-Sender: r.zharkov@postgrespro.ru User-Agent: Roundcube Webmail/1.2.4 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, Can anybody explain me that strange behavior? select random() as "rnd", random() as "rnd1", random() as "rnd2" from generate_series( 1, 5 ); --- 0.948556384071708 0.769186236895621 0.381390900816768 0.684488877654076 0.594888080842793 0.214444123208523 0.668408528901637 0.452859566546977 0.924952184315771 All of the values are different. select random() as "rnd", random() as "rnd1", random() as "rnd2" from generate_series( 1, 3 ) order by random(); --- 0.166236794553697 0.166236794553697 0.166236794553697 0.629051928408444 0.629051928408444 0.629051928408444 0.698161978274584 0.698161978274584 0.698161978274584 All values in any row are the same. select random() as "rnd", random() as "rnd1", random() as "rnd2" from generate_series( 1, 3 ) order by random() || 'test'; --- 0.569052047561854 0.531697370111942 0.338135569822043 0.880468992516398 0.172520748339593 0.0296505615115166 0.862012444529682 0.119546371512115 0.21626165881753 All of the values are different again. Is it a bug?