Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNztn-0001er-Ja for pgsql-general@arkaria.postgresql.org; Tue, 07 May 2019 13:12:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hNztl-0007Yv-7K for pgsql-general@arkaria.postgresql.org; Tue, 07 May 2019 13:12:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNztk-0007XZ-P6 for pgsql-general@lists.postgresql.org; Tue, 07 May 2019 13:12:44 +0000 Received: from q7r7.com ([8.9.8.112] helo=50pop.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNztd-00035b-Nb for pgsql-general@lists.postgresql.org; Tue, 07 May 2019 13:12:43 +0000 Received: from localhost (50pop.com [local]) by 50pop.com (OpenSMTPD) with ESMTPA id 6cb8dc90 for ; Tue, 7 May 2019 09:12:36 -0400 (EDT) Date: Tue, 7 May 2019 09:12:36 -0400 From: Myles Miller To: pgsql-general@lists.postgresql.org Subject: Re: random generated string matching index in inexplicable ways Message-ID: <20190507131236.GA62383@50pop.com> References: <20190507115345.GA56585@50pop.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > > # SELECT y FROM x WHERE y = chr(round(random())::int + 65); > > y > > --- > > A > > B > > (2 rows) > Here you got a random value in the lower range of 0..1 for the record with value ‘A’, so that’s a match, and one in the higher range for value ‘B’, a match again, so you get 2 rows. No, the function is returning just one letter, either 'A' or 'B', not multiple values. # SELECT * FROM chr(round(random())::int + 65); chr ----- B (1 row) # SELECT * FROM chr(round(random())::int + 65); chr ----- A (1 row)