Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5DFBD9FBB72 for ; Thu, 29 Mar 2007 12:46:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 28298-03 for ; Thu, 29 Mar 2007 12:46:13 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web31815.mail.mud.yahoo.com (web31815.mail.mud.yahoo.com [68.142.206.168]) by postgresql.org (Postfix) with SMTP id 6C4D99FBA85 for ; Thu, 29 Mar 2007 12:46:14 -0300 (ADT) Received: (qmail 52367 invoked by uid 60001); 29 Mar 2007 15:46:12 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=cYHLVj/P0yYVGiLIZ441+/57e/fX9FW4F1nvCe9c+JFM1ri2pE9TbqrtIZ9FmPxIratTEi6R9JhuoAXZr7g5AJ5n/2jy5U2bImHJDaHG/ur5KoLan6fY2bu1/DpWgj6gwh1eVzGdBRmu5QHEx0G9EXIC0LOep65MdqGeU1lWWgQ=; X-YMail-OSG: lOXGvKYVM1mfm4c5SYMqccafIW0uLf7ZsDdImm6UGfIEY49NP8FC8fU6kX4w7ngtz9YRCQ-- Received: from [63.203.180.122] by web31815.mail.mud.yahoo.com via HTTP; Thu, 29 Mar 2007 08:46:12 PDT Date: Thu, 29 Mar 2007 08:46:12 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Temp tbl Vs. View To: radhika@88thstreet.com, pgsql-sql@postgresql.org In-Reply-To: <60666.63.118.86.10.1175181985.squirrel@www.88thstreet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <353111.48354.qm@web31815.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.053 tagged_above=0 required=5 tests=AWL=-1.117, BAYES_40=-0.185, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, DNS_FROM_RFC_WHOIS=1.447 X-Spam-Level: ** X-Archive-Number: 200703/347 X-Sequence-Number: 27985 > select from the view is taking a lot of time (7000 ms) as per explain > analyze. Both the primary and secondary tables have about 400,000 rows. > > My question is how can I fix this? > Would it be better to create a temporary table for just daily data and > have the view for more extended queries? Any other design ideas? Perhaps tsearch2 would work for you. I am just starting to learn about it. Maybe you can create a tsearch2 GIN index on each table in the view, and then use tsearch2 queries to quickly retrieve your results. Regards, Richard Broersma Jr.