Android and desktop Java library
(1) By Andrzej on 2021-09-11 09:14:24 [link] [source]
import android.database.sqlite is accessible from standard Android library? How to use SQLite with Java for desktop? I want make portable library for test on desktop, using with Android app. I need make wrapper of two SQLite libraries?
(2) By Simon Slavin (slavin) on 2021-09-11 16:39:59 in reply to 1 [link] [source]
There is no clear agreement that one of these is definitely the best option for all SQLite development. You will need to do some reading and make some choices.
I don't know enough about Java to answer that part of your question.
(3) By Andrzej on 2021-09-11 19:46:05 in reply to 2 [link] [source]
I have today written simple wrapper for libraries and test the same code on Laptop Core I3 8th Gen and Samsung A42.
I create 10'000 rows , each with column "to jest text" and float. Moreover I add two indices, unique for column 2 and not unique on column 1+2.
First I have 22 seconds on laptop; I make one transaction and I have only 150 ms. On Samsung phone 1000 ms.
Why? Phone cores are slower, but phone has more cores. Is possible run one transaction on more than one core in SQLite. Is possible further optimization in Java?
(4) By anonymous on 2021-09-12 09:51:21 in reply to 3 [link] [source]
Phone cores are slower, but phone has more cores. Is possible run one transaction on more than one core in SQLite.
Transaction is mostly an I/O operation. SQLite may perform sorting in parallel if you enable the option, but more CPU cores won't be able to speed up I/O. Indeed, I/O is so much slower than CPU that we had invented caches for our storage devices in memory. Also, memory is so much slower than the CPU that there are memory caches in the CPU, usually multiple levels of them.
(5) By Simon Slavin (slavin) on 2021-09-12 14:09:16 in reply to 3 [source]
I assume you mean that all 10,000 rows are part of the same transaction. It might go faster if you try 1,000 rows and use ten transactions. Or it might not.
SQLite's processing is extremely fast. Almost all the time taken by SQLite is about storage access. Don't think about cores and GHz, think about memory bus speed, and time taken to read and write a sector.
Your Samsung phone is writing to Flash memory. Your laptop is passing the data to a storage subsystem, which stores it in a RAM cache then says "job done" (also in the background writes the cache to the real storage). Flash memory is slower than RAM.
(6) By Keith Medcalf (kmedcalf) on 2021-09-13 00:44:45 in reply to 3 [link] [source]
The fastest way to perform I/O is to not do it.
It would appear that "Samsung phone" does I/O 10 times slower than "laptop".
(7) By Keith Medcalf (kmedcalf) on 2021-09-13 00:55:36 in reply to 6 [link] [source]
A an aside, I have "samsung phone" and also "laptop". However in my case "samsung phone" I/O is slower than "laptop" by a factor of almost 1,000,000.