Page 1 of 1

Load big BLOB data from MySQL -> progress bar needed

Posted: Thu 11 Aug 2016 08:15
by wjjw73
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

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

Posted: Thu 11 Aug 2016 09:05
by ViktorV
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

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

Posted: Thu 11 Aug 2016 15:30
by FCS
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

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

Posted: Tue 01 Nov 2016 10:35
by ViktorV
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.