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 1gzaEF-0008U1-Bj for pgsql-general@arkaria.postgresql.org; Fri, 01 Mar 2019 04:56:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzaED-0002QW-Sx for pgsql-general@arkaria.postgresql.org; Fri, 01 Mar 2019 04:56:57 +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 1gzaED-0002QP-IC for pgsql-general@lists.postgresql.org; Fri, 01 Mar 2019 04:56:57 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzaDx-0000wP-T5 for pgsql-general@lists.postgresql.org; Fri, 01 Mar 2019 04:56:57 +0000 Received: by mail-oi1-x235.google.com with SMTP id u128so18537120oie.2 for ; Thu, 28 Feb 2019 20:56:41 -0800 (PST) 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-language; bh=70bnoCILRecvqVMqDeEAuOpijKN8PwJ9yyY8ViTxqCY=; b=RbJG4WfazkGj88FtNzSbF4aBzTrtJMFRUkfEYr0nOylqAb0d3T6ngiMPFw7JsNJgbE mA10cWfmB5ziL1d2PHBauZ++aA69u9mgYYvS2tjMAvMSWz6UWpYOWsPF9SqFUDodwdhA IOnOzMKh5W/2HtW8JBbjrmdpIFYc7WF47TwlV/SIA8ls9uEV8YQRkfQc29GpdhuDmgjp 7Y77UT35YGAPX/9l0xQkGHDafebG9TA0Zuib1E15Azn4NQa0aODqvRCR15XmfnGc6a93 4Km5cWEu5a1JKHAnO9gbArKSz9SpAhofWZRiBL6EDuuQQWsk5sKRHeL3TdFm4gqnY+Iz HITQ== 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-language; bh=70bnoCILRecvqVMqDeEAuOpijKN8PwJ9yyY8ViTxqCY=; b=PT9F1P8+YvGe+n6/H2TqTVkxEGS8kvBaa1XVmqKKXl3knAbam860feiHP2fvOyue7p A828Ij6aAtnss74nV7MtVG2QC0YpyJVMKL6UYBp9kXq2WABIVNpXACnkl4hRyp8JlHpJ jV4yVhlTZY3k9l8WGWk8SaH19QOy94enzs9gVeXK0B70ZhJn8NK9ETk6YXHR7ZxwmFc7 fKFKYfRA4GJX7rDMowTLbibOeuetOieUkAtmDBPvGtYSibYB0eruhFlI9RZQ6HA3QiMF O+4S2qwMlzIxbw/hQTEV1cznyWBluTDIamhK7kuJQzFPzJ1MvATe2tBv0FKwuYDh3f4l fSNg== X-Gm-Message-State: AHQUAuZIaX6OXjRE2F+g65K9vItG7RSFTezsJLLMmAbpOJ8d6kmX10c7 M/sgx+kNeWpwR2kpU/K2mJMkpq1m X-Google-Smtp-Source: AHgI3IaZF6Q2hloY7RcS3jfMnpapB1xABXdrBC5sb5uqY8vZFqme9lJSYZSyTL0QJ0FQy8Prgj2k9Q== X-Received: by 2002:aca:ecd5:: with SMTP id k204mr2006782oih.153.1551416199483; Thu, 28 Feb 2019 20:56:39 -0800 (PST) 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 l6sm8371294otf.63.2019.02.28.20.56.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 20:56:38 -0800 (PST) Subject: Re: Overloaded && operator from intarray module prevents index usage. To: PostgreSQL General References: <10517.1551372290@sss.pgh.pa.us> <1650.1551393260@sss.pgh.pa.us> <4364c5c4-da6f-a532-8a9b-c5f2a80b0882@gmail.com> <16afa0dd-5520-34bd-0ea5-bedc8e2096cb@gmail.com> From: Ron Message-ID: <25e02082-6023-8669-c9f6-23d71e20abec@gmail.com> Date: Thu, 28 Feb 2019 22:56:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------CB3463B0AD060A01B9CDAA1B" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------CB3463B0AD060A01B9CDAA1B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2/28/19 10:26 PM, Michael Lewis wrote: > > Arrays are -- by definition -- not atomic, and so they fundamentally > break the model that relational databases are founded upon.  If you > want to be a good database designer, don't use arrays. > > > Thanks. I was reading about Codd after your last email, but couldn't guess > at which point was objectionable. I'll have to keep that in mind and > always question when I come across an array or if I am ever tempted to use > one. > > While I can make more minor modifications to schema and suggest best > practices, I am not in the position to set or enforce policy within my > organization. The table and field in question are absolutely a mess and > this field in particular is actually an array of IDs of other records on > the same table (that actually represent another object that is similar but > not the same as the one containing the array of IDs). > > So, I am just looking to make the best of a bad situation currently and > understand how best to use the various tools available to me, with little > impact on the existing codebase but still getting performance benefits > from proper indexing. Thanks for sharing the additional context. > Don't worry.  I'm just in an especially "geezer" mood today. -- Angular momentum makes the world go 'round. --------------CB3463B0AD060A01B9CDAA1B Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 2/28/19 10:26 PM, Michael Lewis wrote:
Arrays are -- by definition -- not atomic, and so they fundamentally break the model that relational databases are founded upon.  If you want to be a good database designer, don't use arrays.

Thanks. I was reading about Codd after your last email, but couldn't guess at which point was objectionable. I'll have to keep that in mind and always question when I come across an array or if I am ever tempted to use one.

While I can make more minor modifications to schema and suggest best practices, I am not in the position to set or enforce policy within my organization. The table and field in question are absolutely a mess and this field in particular is actually an array of IDs of other records on the same table (that actually represent another object that is similar but not the same as the one containing the array of IDs).

So, I am just looking to make the best of a bad situation currently and understand how best to use the various tools available to me, with little impact on the existing codebase but still getting performance benefits from proper indexing. Thanks for sharing the additional context.

Don't worry.  I'm just in an especially "geezer" mood today.

--
Angular momentum makes the world go 'round.
--------------CB3463B0AD060A01B9CDAA1B--