X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1BE1432C302 for ; Fri, 15 Oct 2004 08:37:37 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13616-05 for ; Fri, 15 Oct 2004 07:37:32 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 2BCF132C30B for ; Fri, 15 Oct 2004 08:37:33 +0100 (BST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) id 1CIMeu-0004g7-9m; Fri, 15 Oct 2004 07:38:06 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5F20C15A0F; Fri, 15 Oct 2004 08:37:07 +0100 (BST) Message-ID: <416F7E22.6000702@archonet.com> Date: Fri, 15 Oct 2004 08:37:06 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Igor Maciel Macaubas Cc: pgsql-performance@postgresql.org Subject: Re: View & Query Performance References: <001301c4b231$280c4190$6801a8c0@providerst.local> In-Reply-To: <001301c4b231$280c4190$6801a8c0@providerst.local> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/208 X-Sequence-Number: 8684 Igor Maciel Macaubas wrote: > Hi all, > > I'm trying to find smarter ways to dig data from my database, and > have the following scenario: > > table1 -- id -- name . . . . . . > > table2 -- id -- number . . . . . . > > I want to create a view to give me back just what I want: The id, the > name and the number. I tought in doing the following: create view > my_view as select t1.id, t1.name, t2.number from table1 as t1, table2 > as t2 where t1.id = t2.id; > > Will this be enough fast ? Are there a faster way to make it work ?! > This table is mid-big, around 100K registers .. That's as simple a way as you will find. If you apply further conditions, e.g. SELECT * FROM my_view WHERE id = 123; then you should see any index on "id" being used. -- Richard Huxton Archonet Ltd