effizient query with jdbc

From: Bühler, Johannes <jbuehler(at)geotask(dot)ch>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: effizient query with jdbc
Date: 2005-12-15 06:22:47
Message-ID: 618D880A81409C48B2766AFACEAC37EEFBE717@x401.p01.prodv.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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();
}
...

Browse pgsql-performance by date

  From Date Subject
Next Message Mitchell Skinner 2005-12-15 06:52:47 Re: Simple Join
Previous Message Tom Lane 2005-12-15 05:36:20 Re: [postgis-users] Is my query planner failing me, or vice versa?