X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6459AD1B19C for ; Tue, 25 May 2004 19:32:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49303-06 for ; Tue, 25 May 2004 19:32:06 -0300 (ADT) Received: from outputservices.com (outputt1130.customer.frii.net [216.17.159.130]) by svr1.postgresql.org (Postfix) with ESMTP id 75C66D1B175 for ; Tue, 25 May 2004 19:31:58 -0300 (ADT) Received: from outputservices.com (outputservices.com [137.106.76.15]) by outputservices.com (8.11.3/8.11.3) with ESMTP id i4PMOJ901032; Tue, 25 May 2004 16:24:24 -0600 (MDT) Message-ID: <40B3C792.3020106@outputservices.com> Date: Tue, 25 May 2004 16:24:18 -0600 From: Marty Scholes User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.9) Gecko/20020517 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Vitaly Belman Cc: Jochem van Dieten , pgsql-performance@postgresql.org, Marty Scholes Subject: Re: PostgreSQL caching References: <20792805375.20040521203337@012.net.il> <40B36848.1090403@oli.tudelft.nl> <1371146711781.20040525225305@012.net.il> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/209 X-Sequence-Number: 7040 Vitaly, This looks like there might be some room for performance improvement... > MS> I didn't see the table structure, but I assume > MS> that the vote_avg and > MS> vote_count fields are in bv_bookgenres. > > I didn't understand you. vote_avg is stored in bv_books. Ok. That helps. The confusion (on my end) came from the SELECT clause of the query you provided: > SELECT bv_books. * , > vote_avg, > vote_count All fields from bv_books were selected (bv_books.*) along with vote_agv and vote_count. My assumption was that vote_avg and vote_count were therefore not in bv_books. At any rate, a query with an IN clause should help quite a bit: SELECT bv_books. * FROM bv_books WHERE bv_books.book_id IN ( SELECT book_id FROM bv_genres WHERE bv_bookgenres.genre_id = 5830 ) ORDER BY vote_avg DESC LIMIT 10 OFFSET 0; Give it a whirl. Marty