RE: JDBC driver GREATLY speeded up by trivial fix

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: "'William Chesters'" <williamc(at)paneris(dot)org>, pgsql-interfaces(at)postgresql(dot)org
Cc: "Hermit Hacker (E-mail)" <scrappy(at)hub(dot)org>
Subject: RE: JDBC driver GREATLY speeded up by trivial fix
Date: 2000-07-31 08:36:55
Message-ID: 1B3D5E532D18D311861A00600865478CF1B18A@exchange1.nt.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

You'll need to ask the hermit for CVS access ;-)

Peter

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council

-----Original Message-----
From: William Chesters [mailto:williamc(at)paneris(dot)org]
Sent: Monday, July 31, 2000 9:30 AM
To: pgsql-interfaces(at)postgresql(dot)org;
melati_development(at)messageboards(dot)paneris(dot)org
Subject: RE: [INTERFACES] JDBC driver GREATLY speeded up by trivial fix

Peter Mount writes:
> As for receiveString(), it predates the driver merger (some 2 years ago?)
so
> as it's never broke it's been left. I suspect there's a lot of little
> performace gems in there if we had time to sit down and do them.

Well, nothing else really leaps out the profiling data. It looks like
the effect of further improvements will be relatively marginal
compared with the unavoidable time spent on socket reads/writes, and
of course waiting for the backend to do its stuff.

> I'm currently having horrible problems with my home system (hasn't
recovered
> well after the move)

sympathy ...

If you gave me a CVS p/w I could apply the ReceiveString fix and my
private fix for getTimestamp??

By the way, I've also got a rough implementation of
DatabaseMetaData.getIndexInfo---appended, with test harness---which
certainly does something, whether the JDBC-ly correct thing I don't
know!

Thanks,
William

public java.sql.ResultSet getIndexInfo(String catalog, String schema,
String table, boolean unique,
boolean approximate)
throws java.sql.SQLException {

return ((Connection)getConnection()).ExecSQL(
"SELECT " +
"null AS TABLE_CAT, null AS TABLE_SCHEMA, t.relname AS TABLE_NAME,
" +
"NOT i.indisunique AS NON_UNIQUE, null AS INDEX_QUALIFIER, " +
"ti.relname AS INDEX_NAME, " + tableIndexOther + " AS TYPE, " +
"i.indkey[0] AS ORDINAL_POSITION, a.attname AS COLUMN_NAME, " +
"NULL AS ASC_OR_DESC, 0 AS CARDINALITY, 0 AS PAGES, " +
"NULL AS FILTER_CONDITION " +
"FROM " +
"pg_index i, pg_class ti, pg_class t, pg_attribute a " +
"WHERE " +
"ti.oid = i.indexrelid AND t.oid = i.indrelid AND " +
(table == null ?
"" :
"t.relname = '" + StringUtils.escaped(table, '\'') + "' AND ")
+
(unique ? "i.indisunique AND " : "") +
"a.attrelid = i.indrelid AND " +
// this strange little construct is needed because
// `a.attnum = i.indkey[0]' causes 6.4.2 (at least) to fail,
losing
// connection to backend:
"a.attnum - i.indkey[0] = 0");
}

public static void main(String[] args) throws Exception {

java.sql.DriverManager.registerDriver((Driver)Class.forName("postgresql.Driv
er").newInstance());
java.sql.Connection c =
java.sql.DriverManager.getConnection("jdbc:postgresql:" + args[0],
"postgres", "*");
java.sql.DatabaseMetaData m = c.getMetaData();

java.sql.ResultSet inds = m.getIndexInfo(null, "", args[1], false,
true);
while (inds.next())
System.out.println("TABLE_CAT " + inds.getString("TABLE_CAT") + "\n" +
"TABLE_SCHEMA " + inds.getString("TABLE_SCHEMA") +
"\n" +
"TABLE_NAME " + inds.getString("TABLE_NAME") + "\n"
+
"NON_UNIQUE " + inds.getBoolean("NON_UNIQUE") +
"\n" +
"INDEX_QUALIFIER " +
inds.getString("INDEX_QUALIFIER") + "\n" +
"INDEX_NAME " + inds.getString("INDEX_NAME") + "\n"
+
"TYPE " + inds.getShort("TYPE") + "\n" +
"ORDINAL_POSITION " +
inds.getShort("ORDINAL_POSITION") + "\n" +
"COLUMN_NAME " + inds.getString("COLUMN_NAME") +
"\n" +
"ASC_OR_DESC " + inds.getString("ASC_OR_DESC") +
"\n" +
"CARDINALITY " + inds.getInt("CARDINALITY") + "\n"
+
"PAGES " + inds.getInt("PAGES") + "\n" +
"FILTER_CONDITION " +
inds.getString("FILTER_CONDITION") + "\n");
}

Browse pgsql-interfaces by date

  From Date Subject
Next Message S.A.Pamungkas 2000-07-31 11:39:43 couldn't load DB driver : null
Previous Message William Chesters 2000-07-31 08:29:59 RE: JDBC driver GREATLY speeded up by trivial fix