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 1hS9VC-0004LY-9F for pgsql-general@arkaria.postgresql.org; Sun, 19 May 2019 00:16:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hS9VA-0007zX-6E for pgsql-general@arkaria.postgresql.org; Sun, 19 May 2019 00:16:32 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hS9V9-0007zQ-QZ for pgsql-general@lists.postgresql.org; Sun, 19 May 2019 00:16:31 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hS9V2-0000IU-Io for pgsql-general@lists.postgresql.org; Sun, 19 May 2019 00:16:30 +0000 Received: by mail-ot1-x32e.google.com with SMTP id l25so1586867otp.8 for ; Sat, 18 May 2019 17:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=6D3SBtlC+vGM5Q5n+cbMVQIuLCxoJlx2nLGkoea9wDs=; b=UygFuzqIuL0cHMtdiqHGAnnVwo8yYRPjF6lbgZ1TlulZDOKGmxupdjtJ4w6lt915fv 9U2GjYzbERj+HWU5d58//PAavDvYuU8+tzCV36ESfv5SD+aW8rNyhCMW/1fBHzn+HiMQ 0KiJHAI94XQ6VzcIwYpiGvw8pA884oA160B3TrXyDbJOCzbIuWdcD1INYaucSbNZJZvh ROcUMc+M5xyK6eG9OH0GN1ZPkP3enWu66r8z6qYOQrcoundeBncnLCv6p9v/VZL7GSr9 L4R41cSvygAg28ke3ue+ZFjoh1HpM7SFa9qK4FoTx4IjusZcUFodIznTiY8y2wWavnTT m2Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6D3SBtlC+vGM5Q5n+cbMVQIuLCxoJlx2nLGkoea9wDs=; b=XVHx8JimYyC3VCw1F+EOe6kZiNzHBMronwAfLGo0TdWq8O07PXeJ5MPB0Qd4neqhm4 RPX4/I3b26qBl8j30YDvo/HMB0/Ly9L27AB7NL/ffQ71U2gyIcQQ3JAeEPmt+XkB0gwI y6UnZXK5RPMfbUR/fvZ8lxxdk8VeXZd8Z0Micu6OLDBgTOc/UkzyIODFG6rGK8jWD0d7 BtOUcN29Y7lk7pUCXhnkMhUVROCetZD8N3/YzQLbjZnKjH7XwXss7c4rEvGdKanvNuxf /HvxLbvBy8CYGoriWsFoqmlgHQOaLZk8yE4dJHlgO7gOSyX0sQ3kK4vY4QOfm7mGpLKi V5iQ== X-Gm-Message-State: APjAAAV2xFHgisomU3VRbgHiVTfwg8jgSuwmajAbdUooRIfJR0rPGRkL OnQaJFfJcQAMD4WQab2Fafuc/101s7o= X-Google-Smtp-Source: APXvYqwAAxCPcBaTtRJnbH2OQuDWcdZslz4fCpG5hJ9/mgE7HBeV9F5mF9MPIndbYsN//t+37puS/w== X-Received: by 2002:a05:6830:1506:: with SMTP id k6mr20218547otp.344.1558224981162; Sat, 18 May 2019 17:16:21 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id e133sm4608232oif.44.2019.05.18.17.16.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 May 2019 17:16:20 -0700 (PDT) Subject: Re: bigint out of range To: pgsql-general@lists.postgresql.org References: <20190518093519.2kd6hyw37wcx6qwc@hjp.at> <20190518192703.ml6duizgdyfyetva@hjp.at> <20190518204941.d2o5xy2b53r266ws@hjp.at> <55d8ce6e-2a94-1003-0fc1-66a39d6d2e8a@gmail.com> <20190518223952.g5jrsyj5us7kytpb@hjp.at> From: Ron Message-ID: <0bea576e-43df-9176-a5da-1aea2bb1b337@gmail.com> Date: Sat, 18 May 2019 19:16:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190518223952.g5jrsyj5us7kytpb@hjp.at> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/18/19 5:39 PM, Peter J. Holzer wrote: > On 2019-05-18 17:14:59 -0500, Ron wrote: >> On 5/18/19 3:49 PM, Peter J. Holzer wrote: >> >> On 2019-05-18 15:19:22 -0500, Ron wrote: >> >> On 5/18/19 2:27 PM, Peter J. Holzer wrote: >> >> On 2019-05-18 10:49:53 -0700, David G. Johnston wrote: >> >> You don’t perform math on a hash >> >> That's not generally true. Hashes are used for further computation for >> example in hash tables or in cryptography. >> >> How is it "using math" to use a hash key in a hash lookup table? >> >> hash modulo table size. >> >> >> I've seen that used when the tablespace is pre-allocated, and you hash modulo >> the tablespace page number.  (Yes, performance tanks when you start filling up >> pages.)  How do you hash on the (ever growing) table size? > The hash function returns a number in a range much larger than the > possible number of buckets. 64 bits is a good choice today. > > To determine the bucket you need to reduce this number to something in > the range [0, nr_buckets). This is where modulo comes in: > > i = h % nr_buckets > > If the the table fills up, you increase nr_buckets, reallocate and > rehash all entries. Ouch.  Response time on a big table would take a serious hit if that rehash happened in the middle of the day on a big OLTP system.  Even worse if it were a 24x365 system, because you couldn't schedule an enlargement/rehash during a down period. -- Angular momentum makes the world go 'round.