X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 5C8C59DCAAF for ; Thu, 22 Dec 2005 10:17:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90296-09 for ; Thu, 22 Dec 2005 10:17:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id E4E4B9DC886 for ; Thu, 22 Dec 2005 10:17:41 -0400 (AST) Received: (qmail 8120 invoked from network); 22 Dec 2005 14:17:46 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 22 Dec 2005 14:17:46 -0000 In-Reply-To: <200512151444.jBFEiNF25690@core.kontent.de> References: <200512151444.jBFEiNF25690@core.kontent.de> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1380B56B-1419-4F4D-894B-979F075F18CF@fastcrypt.com> Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: effizient query with jdbc Date: Thu, 22 Dec 2005 09:17:45 -0500 To: johannesbuehler@oderbruecke.de X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] X-Spam-Score: 0.129 X-Spam-Level: X-Archive-Number: 200512/570 X-Sequence-Number: 16391 The problem is you are getting the entire list back at once. You may want to try using a cursor. Dave On 15-Dec-05, at 9:44 AM, johannesbuehler@oderbruecke.de wrote: > Hi, > I have a java.util.List of values (10000) which i wanted to use for > a query in the where clause of an simple select statement. > iterating over the list and and use an prepared Statement is quite > slow. Is there a more efficient way to execute such a query. > > Thanks for any help. > Johannes > ..... > List ids = new ArrayList(); > > .... List is filled with 10000 values ... > > List uuids = new ArrayList(); > PreparedStatement pstat = db.prepareStatement("SELECT UUID FROM > MDM.KEYWORDS_INFO WHERE KEYWORDS_ID = ?"); > for (Iterator iter = ids.iterator(); iter.hasNext();) { > String id = (String) iter.next(); > pstat.setString(1, id); > rs = pstat.executeQuery(); > if (rs.next()) { > uuids.add(rs.getString(1)); > } > rs.close(); > } > ... > > > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: explain analyze is your friend >