Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwxaS-0000vV-7A for pgsql-sql@arkaria.postgresql.org; Sat, 08 Apr 2017 21:08:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cwxaR-00072T-KZ for pgsql-sql@arkaria.postgresql.org; Sat, 08 Apr 2017 21:07:59 +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.84_2) (envelope-from ) id 1cwxaR-00071E-4a for pgsql-sql@postgresql.org; Sat, 08 Apr 2017 21:07:59 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cwxaH-0007I7-R9 for pgsql-sql@postgresql.org; Sat, 08 Apr 2017 21:07:58 +0000 Received: by mail-pf0-x22e.google.com with SMTP id s16so17822695pfs.0 for ; Sat, 08 Apr 2017 14:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FMqmo38uo7CsFoXwvVOshjAPbWa/J//c9RCMr0EC06k=; b=Ryj6X81WAVW2skYlvlCtLegAnBTjIVlZ4TyZmH9CKpTIUf2+sLgRLGH/nYqj/oeUFX t8e2JwFCK8B5TrKmlesSx1kVhyJ1t+hD1pQzbf+fVqZO4qCdH+xbE6msWSZbTfRlxnTr xXtieESX3c4MfLCQ9GkwMO6MpsRPUQKsF+daXAxCrdHZBz/BCBrK3C+vQznG9iAzO4mE RIbXMGWGkAhZfyl3dPs8FTuWBoio1LpZjDQ8Z0iKtsgQ+pIQt0DIzTjueo3P3Ubh5q1w v9jiffjepguxwbQh/x8inj7D9aYGqzt7zAYjR45oLA20a5nmHKeGVSjGHvryFAml+pZ8 fa1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FMqmo38uo7CsFoXwvVOshjAPbWa/J//c9RCMr0EC06k=; b=JeKfQpNi+KcagdviiKK4VSOXLLiOuFkcgtGVl47/a85dtSt3VoHr8CbCw3pR05rbCr Oggi+aq6c5+6TiubUF7qdQrZdx0yTE4oZ0QiNPAkbzoMyxWejrfbCUBaVJWJA/Pzr0Bf VW3x30T6YYC49EvoUcZKAfKDUHTeQR/SU6d0u+gszlvI9dfFQbZ4UjShWYEyi72POXG7 rVWI9+jdDHF7ixlUBZYTv4+rl7OJlhuj6IIseZ+eHeVPhabgdBKrc79MLn5B1l3XaCtV EOKTnGgHxAdIs/NLe5KLjxuLQ96Q1EjOOL9T7KfAmuweBk6YtZbQ6gzke3HpCWsWdIEb qvvw== X-Gm-Message-State: AFeK/H3T0+A3faWQbiDIvabvd00LhPkIMbQChWO1HzpCSywZuJi7vLmK5dYA53su+5urMA== X-Received: by 10.99.60.77 with SMTP id i13mr49055329pgn.185.1491685666720; Sat, 08 Apr 2017 14:07:46 -0700 (PDT) Received: from [10.0.0.56] (c-98-202-89-42.hsd1.ut.comcast.net. [98.202.89.42]) by smtp.gmail.com with ESMTPSA id s27sm16500013pfi.10.2017.04.08.14.07.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Apr 2017 14:07:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: death of array? From: Rob Sargent In-Reply-To: <223726fa-1013-6fde-b45b-70f5ed6e655f@gmail.com> Date: Sat, 8 Apr 2017 15:07:43 -0600 Cc: "pgsql-sql@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <73B8E1AF-BD4A-4E6A-B192-8394D59EF47C@gmail.com> <58E7319B.9090306@matrix.gatewaynet.com> <5fef6cfe-a47f-4276-f95f-259fb661276a@gmail.com> <223726fa-1013-6fde-b45b-70f5ed6e655f@gmail.com> To: "David G. Johnston" X-Mailer: Apple Mail (2.3273) X-Pg-Spam-Score: -2.0 (--) 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 > On Apr 7, 2017, at 10:17 AM, Rob Sargent wrote: >=20 >=20 > On 04/07/2017 10:02 AM, David G. Johnston wrote: >> On Fri, Apr 7, 2017 at 8:57 AM, Rob Sargent wrot= e: >> Understood but true if any match is found, I need every array member to= match as I want them all to be of a specific people as input into the quer= y (so field =3D all(array_col)) and "field" here would be people_member.pe= rson_id and using that yields zero results in full query (very quickly thou= gh). >>=20 >> =E2=80=8BI didn't actually attempt to comprehend your original email. I= f you want to supply a self-contained, functioning, query and expected outp= ut (ideally something simpler but that covers your main question) I'd be in= clined to dig further. Even a broken one with what you think should work w= ould be >>=20 >> person =3D ALL(persons) doesn't really seem like it will typically work. >>=20 >> Here are the various array operators supplied by PostgreSQL. You might = find one of them helpful. In particular "contains". >>=20 >> https://www.postgresql.org/docs/9.6/static/functions-array.html >>=20 >> David J. >>=20 >> =E2=80=8B >=20 > Well you prodding got me a seriously reduced execution time. Here's the = actual query. The tables are all in the 'seg' schema and not substantively = different than described in first post. >=20 > create temp table opt10aut > as=20 > with optset as ( > select s.id > , s.markerset_id > , s.startbase > , s.endbase > , ((s.events_equal + s.events_greater)/(1.0 * (s.events_less += s.events_equal + s.events_greater))) as pval > from seg.segment s > join seg.probandset i on s.probandset_id =3D i.id > join (select people_id, array_agg(person_id) as persons from seg.peo= ple_member group by people_id) as pa on i.probands <@ pa.persons > join seg.people o on pa.people_id =3D o.id=20 > where > s.markerset_id =3D '61801888-9a81-4187-922c-4d42c0471bea' > and o.name =3D '709' > ) > select m.name > , min(pval) > from optset op > join seg.markerset_member mm on op.markerset_id =3D mm.markerset_id > join seg.marker m on mm.member_id =3D m.id > where > m.basepos between op.startbase and op.endbase > group by m.name >=20 > It is true that this particular people has only 60 members. Our upper en= d would be ~1000. >=20 > rjs >=20 >=20 >=20 What I was hoping for, I guess, is a construct like create table t(id int /*for Achilles*/, idset int[] references v.field)= =20 and it would be understood that each element can be found in (preferably th= e index of) v.field Oh, and an operator to make use of the knowledge something like select * from t join v on t.idset =E2=80=9Care_all_in=E2=80=9D v.field; Thanks to all, rjs =09 --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql