Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwNP9-0002qm-Sv for pgsql-sql@arkaria.postgresql.org; Fri, 07 Apr 2017 06:29:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cwNP9-0007Rw-FD for pgsql-sql@arkaria.postgresql.org; Fri, 07 Apr 2017 06:29:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cwNO7-00044e-38 for pgsql-sql@postgresql.org; Fri, 07 Apr 2017 06:28:51 +0000 Received: from host3.dynacom.ondsl.gr ([62.103.35.211] helo=smadev.internal.net) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cwNO2-0001o6-P8 for pgsql-sql@postgresql.org; Fri, 07 Apr 2017 06:28:49 +0000 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id v376ShOi034204 for ; Fri, 7 Apr 2017 09:28:43 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: death of array? To: pgsql-sql@postgresql.org References: <73B8E1AF-BD4A-4E6A-B192-8394D59EF47C@gmail.com> From: Achilleas Mantzios Message-ID: <58E7319B.9090306@matrix.gatewaynet.com> Date: Fri, 7 Apr 2017 09:28:43 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------040205090608070000080101" X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org This is a multi-part message in MIME format. --------------040205090608070000080101 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 07/04/2017 06:02, David G. Johnston wrote: > On Thu, Apr 6, 2017 at 7:32 PM, Rob Sargent >wrote: > > > I need to gather all segments whose probandset is within in a specified people. > select s.* from segment s > join probandset ps on s.probandset_id = ps.id > --PROBLEM: WOULD LIKE SOMETHING BETTER THAN THE FOLLOWING: > > > ​SELECT s.* implies semi-joins - so lets see how that would work. > > SELECT vals.* > FROM ( VALUES (2),(4) ) vals (v) > WHERE EXISTS ( > SELECT 1 FROM ( VALUES (ARRAY[1,2,3]::integer[]) ) eyes (i) > WHERE v = ANY(i) > ); > // 2 I never understood the love for UUID keys, If he changes UUID for int, install intarray and create this index : CREATE INDEX probandset_probands_gistsmall ON probandset USING gin (probands gin__int_ops); then he'll be able to do .... WHERE .... intset(people_member.personid) ~ probandset.probands ... That would boost performance quite a lot. (in my tests 100-fold) > > ​HTH > > David J. > -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt --------------040205090608070000080101 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 07/04/2017 06:02, David G. Johnston wrote:
On Thu, Apr 6, 2017 at 7:32 PM, Rob Sargent <robjsargent@gmail.com> wrote:

I need to gather all segments whose probandset is within in a specified people.
select s.* from segment s
  join probandset ps on s.probandset_id = ps.id
--PROBLEM: WOULD LIKE SOMETHING BETTER THAN THE FOLLOWING:

​SELECT s.* implies semi-joins - so lets see how that would work.

SELECT vals.* 
FROM ( VALUES (2),(4) ) vals (v)
WHERE EXISTS (
    SELECT 1 FROM ( VALUES (ARRAY[1,2,3]::integer[]) ) eyes (i)
        WHERE v = ANY(i)
);
// 2

I never understood the love for UUID keys, If he changes UUID for int, install intarray and create this index :
CREATE INDEX probandset_probands_gistsmall ON probandset USING gin (probands gin__int_ops);
then he'll be able to do
.... WHERE .... intset(people_member.personid) ~ probandset.probands ...
That would boost performance quite a lot. (in my tests 100-fold)


​HTH

David J.



-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------040205090608070000080101--