Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WmGO3-0007W8-2e for pgsql-sql@arkaria.postgresql.org; Mon, 19 May 2014 05:45:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WmGO2-0006b8-E6 for pgsql-sql@arkaria.postgresql.org; Mon, 19 May 2014 05:45:22 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WmGO1-0006av-8q for pgsql-sql@postgresql.org; Mon, 19 May 2014 05:45:21 +0000 Received: from ore.jhcloos.com ([2604:2880::b24d:a297]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WmGNp-0001IN-7C for pgsql-sql@postgresql.org; Mon, 19 May 2014 05:45:20 +0000 Received: by ore.jhcloos.com (Postfix, from userid 10) id 65E2C1DECC; Mon, 19 May 2014 05:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jhcloos.com; s=ore14; t=1400478307; bh=3vlbWb6iDKBXCG9At1khcDtd+f0+W0nJnLI1di1nqFc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=pyXSYa5obqIQRO/PrefFNuTeXqh1c7QF+H5/B3K8s/nbTjsBFaJvWbEm39g929V2X bxbHQWGHODGeAyttQkK5HSZWmPaluxpjv2/cLVkdrysNGXH5aT0QQPnqDa1th5a0Hq yP6+LOy9ZW1Xf7jeWxclwzsG/4+YIO6m3rwMbeT4= Received: by carbon.jhcloos.org (Postfix, from userid 500) id 3E6BA6001E; Mon, 19 May 2014 05:43:33 +0000 (UTC) From: James Cloos To: Vik Fearing Cc: pgsql-sql@postgresql.org Subject: Re: matching column of regexps In-Reply-To: <537951B6.4070202@dalibo.com> (Vik Fearing's message of "Sun, 18 May 2014 20:35:02 -0400") References: <537951B6.4070202@dalibo.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAACVBMVEX///8ZGXBQKKnCrDQ3 AAAAJElEQVQImWNgQAAXzwQg4SKASgAlXIEEiwsSIYBEcLaAtMEAADJnB+kKcKioAAAAAElFTkSu QmCC Copyright: Copyright 2014 James Cloos OpenPGP: 0x997A9F17ED7DAEA6; url=https://jhcloos.com/public_key/0x997A9F17ED7DAEA6.asc OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6 Date: Mon, 19 May 2014 01:43:33 -0400 Message-ID: Lines: 31 MIME-Version: 1.0 Content-Type: text/plain X-Hashcash: 1:30:140519:vik.fearing@dalibo.com::CoQBKCtD18CCI1zM:00000000000000000000000000000000000000ETOSJ X-Hashcash: 1:30:140519:pgsql-sql@postgresql.org::WyiCa8QXxJpgKVjd:0000000000000000000000000000000000008I8GI X-Pg-Spam-Score: -2.7 (--) 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 >>>>> "VF" == Vik Fearing writes: JC>> Is there a better way to answer the question, "Do ANY rows match?" VF> select exists (select 1 from retest where active is true and ? ~ re); Ah. Yes. I'd forgotten about select exists. I cannot recall whether I ever used it in anger, or just played around after reading about it. It should stick this time. >> Is there a way to index such a table/query? VF> There are several ways to index such a query. If there are very many VF> rows but with only a few being active, then a partial index will do wonders. Its more likely only a few will be inactive. VF> Otherwise, it is possible to use an index for regular expressions using VF> the pg_trgm extension. Perfect. I see trgm index support for ~, et alia is new in 9.3. Exactly the kicks in the skull I needed. Thanks, -JimC -- James Cloos OpenPGP: 0x997A9F17ED7DAEA6 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql