> The database is the database of the perforce,I don't know exactly
> what's the type.
Then it is rather difficult to troubleshoot.
What JDBC driver are you using ? Something from P4 ?
> The getString method is very slow because it allocates every time a
> very big string, and a new one for every call .In java, String
> allocation is very expensive.
It is faster to allocate a String than an InputStream.
You can create millions og Strings per second.
If you have a performance problem, then the string allocation
in getString is not the cause of it.
Arne
tal - 23 Aug 2006 13:23 GMT
> > The database is the database of the perforce,I don't know exactly
> > what's the type.
[quoted text clipped - 15 lines]
>
> Arne
I am using JdbcOdbc driver to connect to Perforce.
I can't explain it but the fact is that the getString method causing
the problem:
When I removed that line and used constant String , the process was
very fast.When I removed anything else but the getString method, i.e
for every row in the ResultSet just get the string and do nothing,it
took about 10 seconds for something like 550 rows in the ResultSet.
So I think this is the problem.
I think that inside of that method there are several big allocations
which cause this,where in InputBuffer I need to allocate memory at the
start and use the same memory at the rest of the loop,un-like getString
which allocates new String (and I think alot bigger then what I need)
every time it called.
Anyway,I still don't understand why my code doesn't work or why I can't
define Clob object - when I do so I get an IOException.
Tal.
Arne Vajhøj - 24 Aug 2006 04:01 GMT
> I am using JdbcOdbc driver to connect to Perforce.
Hm.
The JDBC-ODBC bridge has a very bad repuation.
Arne
tal - 24 Aug 2006 06:20 GMT
> > I am using JdbcOdbc driver to connect to Perforce.
>
[quoted text clipped - 3 lines]
>
> Arne
So what other options do I have ?
Tal
Chris Uppal - 24 Aug 2006 11:14 GMT
> I am using JdbcOdbc driver to connect to Perforce.
Then there are two obvious possibilities. One is that the JDBC/ODBC bridge is
(as Arne suggested) showing one of ways in which it is not suitable for
production use (it isn't /intended/ to be suitable for production use). The
other is that the ODBC driver from Perforce is not up to this -- since Perforce
isn't a database product in any meaningful sense, I would not be surprised to
find that they have given ODBC access little attention beyond what's needed to
make Crystal Reports work.
Taking a look at the source for JDBC/ODBC bridge, it appears that it's own
implementation of getString() uses getAsciiCharacters() internally (at least it
does if the column contains > 32767 bytes of data -- which I assume yours
does, or else there'd be little or nothing to gain by using the stream
interface in the first place). One possible source of oddness, is that if a
stream is used (either internally or because you have asked for it explicitly)
then it'll read the data in binary mode at the ODBC level, and do whatever
conversions are necessary itself. If you do getString() /and/ the amount of
data is small enough to avoid the streaming, then it'll drive IDBC is
character mode -- possibly that is confusing Perforce.
Perforce is not cheap. Presumably the price includes support -- get onto their
support department and have them find the problem.
-- chris
Arne Vajhøj - 24 Aug 2006 12:23 GMT
> I can't explain it but the fact is that the getString method causing
> the problem:
[quoted text clipped - 9 lines]
> which allocates new String (and I think alot bigger then what I need)
> every time it called.
Have you tried getBytes and creating the String yourself ?
Arne
tal - 24 Aug 2006 15:25 GMT
no, I will try it, thanks!
Tal.
Chris Uppal - 23 Aug 2006 13:34 GMT
> > The getString method is very slow because it allocates every time a
> > very big string, and a new one for every call .In java, String
[quoted text clipped - 3 lines]
>
> You can create millions og Strings per second.
That rather depends on how big the string is. If it is in the millions (or
billions) of characters, then allocating it is going to be slow or impossible.
-- chris
Arne Vajhøj - 24 Aug 2006 04:16 GMT
>> You can create millions og Strings per second.
>
> That rather depends on how big the string is. If it is in the millions (or
> billions) of characters, then allocating it is going to be slow or impossible.
The millions per second will not be achievable for large strings.
But the String allocation / database IO ratio should be the
same for big data.
Arne
Chris Uppal - 24 Aug 2006 11:13 GMT
> But the String allocation / database IO ratio should be the
> same for big data.
Certainly the time taken to copy the data into the strings will be in constant
ratio with the IO no matter how big a "gulp" you take at a time[*], but the
allocation overhead itself is not constant in, or proportional to, the size of
the string -- if nothing else it'll fail for large enough strings when a stream
will still be working happily (or not, as in this case ;-)
But it appears that tal's column contains <= 32K in each row (for that column)
so I agree that's unlikely to be the problem here.
-- chris
[*] Assuming it doesn't require multiple re-copying of the input, as with a
StringBuffer, but I don't think it does in this case.