[Patch] Increase Firebird BLOB reading performance
Original Reporter info from Mantis: BigChimp
-
Reporter name: Reinier Olislagers
Original Reporter info from Mantis: BigChimp
- Reporter name: Reinier Olislagers
Description:
Current Firebird/Interbase connection code reads BLOBs using the segment size stored with the BLOB. However, it is always safe to read chunks of maximum segment size (16 bit unsigned integer=65535), which will probably improve performance.
See thread starting http://lists.freepascal.org/lists/fpc-pascal/2011-November/031062.html for details on discussion
Attached patch that applies to FPC 2.7.1 (revision 20 November)
Reinier Olislagers
Steps to reproduce:
Write 80 byte and 65535 blob segments to blobs in Firebird database (can be done with modified test code below).
Read with patched FPC in 65535 byte segments. Compare result with original value of record.
This worked for me on a Firebird 2.5 server (Linux) and FPC x86 on Windows.
Have done performance test on writing fix: 395 versus 260 seconds for a large number of 10MB BLOB writes, but no testing on reading. Should be faster though.
See test code attached.
Additional information:
Comparable change to writing blobs (from default 80 to fixed 65535) was done already by Michael Van Canneyt in revision 19659.
Justification of making blob segment fixed 65535:
- Interbase 6 API guide example on reading BLOBs does the same (IIRC around page 185)
- Confirmation by Ann Harrison on Firebird list: http://tech.groups.yahoo.com/group/firebird-support/message/115826
- tiOPF's FBLib library uses a fixed BLOB_SEGMENT_LEN of 4095 (in FBLDsql.pas)[1] for in both reading & writing blob data, so a fixed size likely works already
- Test works; see Steps To Reproduce
[1] to be changed based on list discussion
Mantis conversion info:
- Mantis ID: 20719
- OS: Windows
- OS Build: Vista
- Platform: x64
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 19683 (#dce13ae0)
- Target version: 3.0.0