Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WfyOj-0006oV-TK for pgsql-performance@arkaria.postgresql.org; Thu, 01 May 2014 21:20:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WfyOj-00087v-Bw for pgsql-performance@arkaria.postgresql.org; Thu, 01 May 2014 21:20:05 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WfyOi-00086a-1J for pgsql-performance@postgresql.org; Thu, 01 May 2014 21:20:04 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WfyOa-00053D-Pg for pgsql-performance@postgresql.org; Thu, 01 May 2014 21:20:03 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WfyOZ-00069p-He for pgsql-performance@postgresql.org; Thu, 01 May 2014 14:19:55 -0700 Date: Thu, 1 May 2014 14:19:55 -0700 (PDT) From: David G Johnston To: pgsql-performance@postgresql.org Message-ID: <1398979195531-5802157.post@n5.nabble.com> In-Reply-To: References: Subject: Re: Optimize query for listing un-read messages MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 3.5 (+++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org How does something like: WITH unreads AS ( SELECT messageid FROM message EXCEPT SELECT messageid FROM message_property WHERE personid=1 AND has_read ) SELECT ... FROM unreads JOIN messages USING (messageid) ; perform? David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Optimize-query-for-listing-un-read-messages-tp5802097p5802157.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance