PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → images stored in hypersql database
images stored in hypersql database
Iniciado por guest, 16,ene. 2015 16:50 - 10 respuestas
Publicado el 16,enero 2015 - 16:50
Hello,

i ve created programs in the past where i have saved images directly into the datafile. But they seem to slow the database down a ridiculous amount, even when ive only had about 5 thumbnail pictures am i doing something wrong? because of this ive been saving the paths and storing the images elsewhere, however i ve started a new project (WB18) that requires quite a few images linked to records, i know i can still create paths and do it as i have been, but i would prefer on this particular project to store them in the database. has anyone had success storing lots of images in a database without a massive dent in its performance?

thanks iso
Publicado el 16,enero 2015 - 17:03
Hi iso

Are you sure the database is causing troubles and not your page, loading several FULL blown images?

I have an image with 2 thumbnails without any problem, stored in hfcs. Database holds 100.000+ images.
My app shows these thumbnails in a looper. After the user picks one, the full image is shown.
Publicado el 16,enero 2015 - 17:07
Hi

I have a 8GB+ DB where about 7GB are blobs (images and videos)
I have ZERO problem, it's fast and nothing changes when I add more blobs

You may have a conception problem...

Now, OF COURSE, if you are using queries returning a ton of records and you INCLUDE the blob in your query, then ALL the images will be read BEFORE you display the first one...

So that will NOT be a good way of coding your app
Publicado el 19,enero 2015 - 12:08
Hi,

Thanks Fabrice maybe thats part of the problem. Are you saying the images (and videos which i didnt even know i could store!) should be in a separate table?

Arie, even when i try to view the datafile with WDMap (with only about 5 images in) it takes ages or crashes!

Are you resizing/compressing the image before saving?

Thanks

ISO
Publicado el 19,enero 2015 - 14:00
Iso,

I just defined 2 or 3 thumbnails in the analysis and that's it.
Whenever I add an image, the hfsql engine creates the thumbnails as well.
Nothing special and no coding what so ever.
The item is denifed as binary memo, maybe that differs from your situation?

As a test I opened a 45GB table with WDMAP. It opens instantly, showing the first 50 records or so. It doesn't load the whole table as once, but read additional data when scrolling. At least for the images. But that's just how wdmap works I guess.
Publicado el 19,enero 2015 - 14:18
I am not saying that you have to have your images and video in a separate file, although you CAN do that

I am saying that you shouldn't do a "select *..." on a file where there are binary memos, as in this case, all of them will be read when they are probably not needed

Best regards
Publicado el 19,enero 2015 - 18:10
Fabrice,

Do you mean that "blobs should be in a separate table" as Iso stated? Can you explain more the "Select" and how can we make the wrong statement?.
Publicado el 19,enero 2015 - 21:47
Hi Luis

no, I means that they CAN be in a separate table, in order to avoid any kind of error when using a query...

If you are doing a query on a file where the record is 200 bytes long and your query returns 1000 records, then you get a 200 KB answer (fast and easy even on the web)

if your query included the blob, then you get 200KN PLUS the total size of all the blobs for the 1000 records, which can means several GBs... And that will be slow, no matter what...

Instead, you always should do your queries WITHOUT the blobs, and when you need to display/use one, you just do a hreadseek and hextractmemo...

If your blobs are in a separate table, you don't even have to read the main record again... And you can never by MISTAKE include the blobs in a query

Best regards
Publicado el 20,enero 2015 - 12:00
I ve been doing some testing putting them in a separate table and it seems to be all ok, so thanks for your help on this. Also Fabrice is there a way of compressing the image for example if users try to add images of 4gb, or is it just a case of resizing the image?

Thanks Arie never noticed the HyperFileSQL thumbnails before,
Publicado el 20,enero 2015 - 12:45
Hi,

WinDev has zip compression capabillities, check out ZipCreate etc. in doc.

Cheers
Tor-Bjarne
Publicado el 20,enero 2015 - 18:28
Thanks Fabrice. Now I understand and got it.