New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crashes when querying all records from a database containing images (blobs) #439
Comments
@Sempervivum have you tried to increase the page-size and cache-size with the PRAGMA |
Thanks for this hint. Unfortunately I'm new to Capacitor and the universe of Android and not familiar with these terms. I'm gonna do some research and give it a try. |
@Sempervivum you do it with an SQL statement that you execute |
Many thanks for this explanation. I see, this is related to SQLite, not Android. I'll give it a try ASAP. |
Many thanks!
I increased the values step by step. |
@Sempervivum sorry but there is nothing i can do more. If you select half of the rows did it work. |
Hi @jepiqueau
Unfortunately this didn't improve speed significantly. |
Remagine what you are doing. It's like every image is reencoded to SQLite blob instead of putting it in plain to the same filesystem. For Images you should use Capacitor Filestorage, good example is basic tutorial on Ionic website. And if needed, like with PWA (using LocalStorage), sync them to server. This will also allow to save images to external storage which mobile users will prefer. SQLite is by design database primarily for text data, it is not as robust as MySQL, Postgres or similar relational DBs. Not that I would suggest using any RDB for images or files. You can hardly optimize it if you running it on the same filesystem as your code. |
Hi @Antarian |
Offline is not a problem with Capacitor FileStorage. But to make bridge between FileStorage and DB Browser would be a "fun" task. Thing which can help here for displaying data back in html is pagination or so called loading data on scroll. One function will only load data from DB (part of it based on pagination). If that would be still slow and you need some quicker pagination for SQLite here is something which should still work: I hope this will help at least a little. |
OK, sorry, you have only one ID used for loading template. I would load it before loop as |
Hi @Antarian BTW: I tried some debugging and noticed in the java sources that there is something like a cursor behind the scenes: Getting one row by one which would make it possible to avoid putting complete result of the query into a huge array. I suspect that this might be another option to avoid crashes. Is that correct? However I can't find a cursor in the docs of the SQLite plugin for capacitor. |
@Sempervivum For me the best will be to use a select with a LIMIT to two times the number of images that you can see simultaneously in your application page and when you slide up or down in your page manage to make a new SELECT containing the next or previous images. Your solution is also valid. |
Describe the bug
My database file is 90MB large and contains 400 records, many of then containing an image blob. Running a query through all records makes the app crash, window disappears from screen. When running the same code on a smaller database (say 20 records, 4 images) there are no issues.
To Reproduce
Running this code makes the app crash:
Expected behavior
Query should run and complete without issues
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
When running the query without images, i. e.
"select Name, Art, Beschreibung from
Substanzen - Substanzen
"it's running without issues. I was able to create a running workaround by selecting the texts in a first step and then querying the images one by one:
The text was updated successfully, but these errors were encountered: