This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 255879 - Querying blob columns results in excessive CPU usage
Summary: Querying blob columns results in excessive CPU usage
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 8.1
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: matthias42
URL:
Keywords:
: 255847 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-10-12 16:12 UTC by brettryan
Modified: 2016-02-02 11:47 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Add missing write(byte[] b, int offset, int len) method to RandomAccessOutputStream (881 bytes, patch)
2015-10-13 20:14 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description brettryan 2015-10-12 16:12:47 UTC
Performing a query on a table that has a reasonably sized BLOB value results in the IDE producing high CPU usage and takes a relatively long time for the results to appear.

Tested with h2database with the following structure

create table if not exists msg_attachment (
  id              identity,
  file_name       varchar(200)  not null,
  file_data       blob,
  file_size       bigint,
  mime_type       varchar(100),
  created         timestamp
);

Created 3 records, 146KiB, 1.6MIB, 302MiB, these result in < 1sec, ~3sec, ~10 minute execution times for select * from msg_attachment, changing to select id returns atomically.

I understand that this would be due to the IDE saving the results out to a file to support opening the documents after the ResultSet has closed. I think this should be optional, and; I think this support needs improving, testing using spring and downloading the files manually results in the 302MiB file saving in ~2 seconds (from same machine using SSD disks).
Comment 1 matthias42 2015-10-13 20:14:21 UTC
Created attachment 156699 [details]
Add missing write(byte[] b, int offset, int len) method to RandomAccessOutputStream

Thank you for finding this Brett, I had this on my notepad, but my checks were with much smaller blob, which had less impact. I can verify your results and agree, that this is unacceptable.

I'll have to check whether I can get the fix into 8.1 as the release has hit high resistance mode.

I attached the patch here, if you can it would be good if you could do a netbeans build with that applied to verify the patch.
Comment 2 matthias42 2015-10-14 15:49:21 UTC
The fix is pushed as:

http://hg.netbeans.org/core-main/rev/9f966a7d730e

As usual in the next few days a nightly build will be available that contains this fix. Please check that build (a message is posted here when it is done) and report whether or not you think this bug is resolved by it.

I'll try to get it into the release if you can verify the fix.
Comment 3 matthias42 2015-10-14 15:55:14 UTC
*** Bug 255847 has been marked as a duplicate of this bug. ***
Comment 4 Quality Engineering 2015-10-15 01:22:31 UTC
Integrated into 'main-silver', will be available in build *201510150002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/9f966a7d730e
User: Matthias Blaesing <matthias42@netbeans.org>
Log: #255879: Querying blob columns results in excessive CPU usage

Cause: missing delegation/override of "write(byte[] data, int offset, int len)" in RandomAccessOutputStream
Comment 5 Jiri Kovalsky 2015-10-15 09:44:19 UTC
Brett, can you please urgently verify Matthias' bug fix in the last development build #201510150002 [1]? Thanks a lot!

[1] http://bits.netbeans.org/dev/nightly/latest/
Comment 6 brettryan 2015-10-16 23:59:42 UTC
Apologies, will get onto it today, I've just been a bit busy with my wife in hospital.  TBH I still feel that 255498 and 249248 are MUCH more important than this one. I think this issue may already exist in 8.0.2 anyway.
Comment 7 brettryan 2015-10-18 21:52:27 UTC
Thanks guys, verified fix and is working fine.

Apologies for the delay in testing.
Comment 8 Jiri Kovalsky 2015-10-19 18:23:27 UTC
This should be fixed in the first available 8.1 patch.
Comment 9 matthias42 2016-01-27 12:25:46 UTC
Patch was transplanted into release81 as:

http://hg.netbeans.org/releases/rev/4ad5f2043d59
http://hg.netbeans.org/releases/rev/8b44ea3c8f9f

Target Milestone should be 8.1.1, as this is not present as value, value was left as Dev.

The patch can be verified by:

1. Create a table with at least one blob column
2. Add some large blobs to the table
3. Query the table (select * from <table>)

With four rows and a blob size of 10MB on an mysql server. I measured (realtime, not reported time):

Without the patch: ~ 40s fetch time
With the patch: ~2s fetch time

The patch is also visible when inserting/updating blobs, the data is first read into the pseudo blob and this is process is also much faster (not measured).
Comment 10 Jiri Kovalsky 2016-01-27 14:38:10 UTC
Thanks a lot Matthias!