Minor performance improvements

From: "Stephen Denne" <Stephen(dot)Denne(at)datamail(dot)co(dot)nz>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Minor performance improvements
Date: 2007-02-26 21:51:45
Message-ID: F0238EBA67824444BC1CB4700960CB48024CDC7A@dmpeints002.isotach.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Four small optimizations in org.postgresql.core.PGStream:

1) The int to byte conversion is not needed in this method:

public void SendChar(int val) throws IOException
{
pg_output.write((byte)val);
}

(I found this while profiling a test that included about 5000 queries. This method was called half a million times, and actually had the third largest "own time" behind executeBatch and executeQuery)

2) The byte masks are not required in SendInteger4 and SendInteger2, as OutputStream.write(int) ignores the top 24 bits. Though if these are removed I think comments should be included instead to clarify that only the bottom eight bits get written.

3) The method with the signature: void Send(byte buf[], int off, int siz),
Could be rewritten so that the test occurs once instead of twice: (buf.length - off) < siz

4) two new parameterless methods should be added to optimize int ReceiveIntegerR(int siz) when called with size 2 and 4, as calls with these parameter values are very common. The call sites should change to use the new methods.

Stephen Denne
Java Developer
Corporate Development
Datamail Ltd
1 Victoria Street
Petone 5012
PO Box 31249
Lower Hutt 5040
Tel: +64 4 568 8200 extension 8638
Fax: +64 4 568 9600
Website: www.datamail.co.nz

</PRE><div style="font-size:8pt;font-family:Tahoma,Arial; text-align:justify; color:gray;"><br><br><hr size="0">At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage.<br><br>This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.<hr size="0"><br><br></div>
</PRE><div style="font-size:8pt;font-family:Arial; text-align:center;"><br><br><hr size="0">
This email has been scanned by the DMZGlobal Business Quality Electronic Messaging Suite.<br>
Please see <a href="http://www.dmzglobal.com/services/bqem.htm">http://www.dmzglobal.com/services/bqem.htm</a> for details.<br>
<hr size="0"><br><br></div>

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-02-26 22:46:38 Re: Minor performance improvements
Previous Message Elizangela 2007-02-26 19:36:37 JDBC do Postgresql 8.1.5