X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3578534A5 for ; Sat, 7 May 2005 15:33:46 -0300 (ADT) 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 65566-07 for ; Sat, 7 May 2005 18:33:41 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 3A93E53AEE for ; Sat, 7 May 2005 13:51:21 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 08394356BD; Sat, 7 May 2005 09:51:19 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 05DBF356B9; Sat, 7 May 2005 09:51:19 -0700 (PDT) Date: Sat, 7 May 2005 09:51:18 -0700 (PDT) From: Stephan Szabo To: Patrice Drolet Cc: pgsql-sql@postgresql.org Subject: Re: Discordance between the way select is called. In-Reply-To: <42753A5A.6030004@infodata.ca> Message-ID: <20050507094623.W62726@megazone.bigpanda.com> References: <42753A5A.6030004@infodata.ca> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/78 X-Sequence-Number: 21391 > Hi, > > I have a java app that uses hibernate to do queries. > > One query on a 6.5 millions records takes about 15 seconds while the > same one (take from the sql that shows in the consol - I configured > hibernate to show_sql) takes about 50 ms when done with pgadmin3. We could answer better with explain output. Something like: prepare foo(int) as select notevalue0_.id as id, notevalue0_.value_note as value2_3_, notevalue0_.actif as actif3_, notevalue0_.id_note as id4_3_, notevalue0_.id_field_name as id5_3_ from note.note_value notevalue0_ where notevalue0_.id_note=$1 and notevalue0_.actif=1; explain analyze execute foo(); - As an initial guess, I'd wonder if it's guessing that for an arbitrary id_note value that it should do a sequence scan. Are there a large number of very common id_note values that might be throwing it off?