X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 98F3F9FB302 for ; Fri, 4 Aug 2006 14:56:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 28008-09 for ; Fri, 4 Aug 2006 17:56:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 452E69FA28E for ; Fri, 4 Aug 2006 14:56:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from smtp135.iad.emailsrvr.com (smtp135.iad.emailsrvr.com [207.97.245.135]) by svr4.postgresql.org (Postfix) with ESMTP id 3E6CE5AFB18 for ; Fri, 4 Aug 2006 17:56:31 +0000 (GMT) Received: from [84.94.12.121] (84.94.12.121.cable.012.net.il [84.94.12.121]) (Authenticated sender: sergey@trafficonnet.com) by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id 3323944C028 for ; Fri, 4 Aug 2006 13:56:01 -0400 (EDT) Message-ID: <44D3983F.60503@gmail.com> Date: Fri, 04 Aug 2006 20:55:59 +0200 From: sergey User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: select query optimization Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: OK X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.269 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, SPF_NEUTRAL X-Spam-Level: * X-Archive-Number: 200608/63 X-Sequence-Number: 26021 Hi all! i run this query select f1,f2 from t1,t2 where t1.url_id=t2.entry_id and (t1.entry_stamp::date>=(now()::date-interval '14 days')) and .... the problem is that t1 is a very big table so the query is too slow. what if i move the second condition to where-clause. Can this reduce the select time? select f1,f2 from (select * from t1 where t1.entry_stamp::date>=(now()::date-interval '14 days' ) as t1,t2 where t1.url_id=t2.entry_id and .... Does this makes sense? (tried to make explain analyze, but it takes too much time) Thank you.