Load big BLOB data from MySQL -> progress bar needed

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wjjw73
Posts: 22
Joined: Fri 17 Aug 2012 09:51

Load big BLOB data from MySQL -> progress bar needed

Post by wjjw73 » Thu 11 Aug 2016 08:15

Hello!

I have a MySQL table with all versions of my application (50+MB per record/version/file).
When I want to access the BLOB field in the DB on the server - I have to wait very long time.
That would be ok - but I cannot show any progress and users are closing the update-app because of this.

Code: Select all

efDM.q_versionfiles.ParamByName('version_id').AsInteger := version_id;
efDM.q_versionfiles.ParamByName('filename').AsString := fn;
efDM.q_versionfiles.Open;  <= this takes ages...
stream := efDM.q_versionfiles.CreateBlobStream(efDM.q_versionfiles.FieldByName('filedata'), bmRead);
Is there a way to somehow read blob data with some blocksize (like streams)?
Or is there another solution for that?

/Werner

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Load big BLOB data from MySQL -> progress bar needed

Post by ViktorV » Thu 11 Aug 2016 09:05

UniDAC reads the entire value of a BLOB field at a single operation, since MySQL doesn't allow to read the value of a BLOB field by blocks. Therefore you can't display this progress.
However, you can display the progress of reading each row. See more details at our forum: viewtopic.php?t=23087

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: Load big BLOB data from MySQL -> progress bar needed

Post by FCS » Thu 11 Aug 2016 15:30

Hello,

If your table has fields like:
ID (autoinc)
FileName (string)
Date (DateTime)
Version (string)
Blob (contents of File)

Try to read and display fields without Blob, by
SELECT ID, FileName, Date, Version FROM atable.

This will take a few moments.

Then display result of this query in a Grid or a List.

When user click on an item of this grid/list then retrieve data stored in the Blob field as you do.

Regards
Michal

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Load big BLOB data from MySQL -> progress bar needed

Post by ViktorV » Tue 01 Nov 2016 10:35

Also to solve your task, you can use the SmartFetch mode. More information about the SmartFetch option you can get on our website: https://www.devart.com/unidac/docs/?dev ... ptions.htm
In the SmartFetch mode, when opening dataset from the DB, the data for only key fields and the fields listed in the PrefetchedFields property for all the records, returned by the query are read. After the table is opened, when accessing any field, the fields reading from the DB for a block of FetchRows records size.
To use the SmartFetch mode you should set in the TUniQuery.SQL.Text of the SELECT property a query, including a BLOB field and set the TUniQuery.SmartFetch.Enabled property to True.

Post Reply