Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 79B01113F981 for ; Sat, 21 Jul 2012 17:29:47 -0300 (ADT) Received: from mail.anatec.com ([87.84.168.242]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SsgJ3-0001dO-HY for pgsql-performance@postgresql.org; Sat, 21 Jul 2012 20:29:46 +0000 Received: from [192.168.10.57] ([192.168.10.57]) by mail.anatec.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sat, 21 Jul 2012 21:29:28 +0100 Message-ID: <500B1128.6020001@anatec.com> Date: Sat, 21 Jul 2012 21:29:28 +0100 From: Ioannis Anagnostopoulos User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Claudio Freire CC: pgsql-performance@postgresql.org Subject: Re: A very long running query.... References: <5007FC82.9070007@anatec.com> <5009CB5A.7070801@anatec.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 21 Jul 2012 20:29:28.0526 (UTC) FILETIME=[86E4C6E0:01CD677F] X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/262 X-Sequence-Number: 47443 On 21/07/2012 21:11, Claudio Freire wrote: > On Sat, Jul 21, 2012 at 5:10 PM, Claudio Freire wrote: >> wrote: >>> (feed_all_y2012m07.ship_pos_messages join >>> ais_server.ship_objects on (ship_pos_messages.obj_id = ship_objects.obj_id)) >>> on (message_copies.msg_id = ship_pos_messages.msg_id) >> It's this part of the query that's taking 3.2 hours. >> >> Move the filtered message_copies to a CTE, and the filtered >> ship_pos_messages join to another CTE. That should (in my experience) >> get you better performance. > Btw... did you try the hash thing? Not yet as I am trying at present to simplify the index getting the georefs out of it. Don't know if this is a good idea but I though that since I am not testing (yet) any equality other than making sure that the georefs are not null or empty, I could avoid having it in the index, thus reducing its size a lot... At least for now.....