Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid 2.3.3 SQLite infinite loop
    primarykey
    data
    text
    <p>In my project, I have 5 tables: Category, CategoryHasProduct, Product, StoreHasProduct and Store. There I store all my products, in which categories they are and in which store which product is available.</p> <p>Now, I want to know how many products in all the categories are available, depending on which store is selected. For performance reasons, I want to use a SQL query for this. The query is</p> <pre><code>SELECT count(*), cp.category_id FROM categoryhasproduct cp, product p, storehasproduct sp WHERE p.sku = cp.product_id AND sp.product_id = p.sku AND sp.store_id = 2 AND sp.isActive = 1 GROUP BY cp.category_id </code></pre> <p>In the Project I use ORMLite. But to query this, I do a basic db-query</p> <pre><code>String query = "..."; SQLiteDatabase db = DBConnector.getConnector(context).getWritableDatabase(); Cursor cursor = db.rawQuery(query, null); </code></pre> <p>Now I have a problem, which makes no sense to me. On Android 4.0.3, everything works fine. The query takes something like 0.5 seconds to run and I can proceed. But when I try to execute the query on Android 2.3.3, the query itself seems to run into an infinite loop. Even after 20 minutes, the query is not finished. On a real device, the processor of the device is getting very hot, so it shuts himself down.</p> <p>As I tried a little bit with the query, it seems that it is to large for sqlite on 2.3.3-devices. the concatenation with the last storehaseproduct-table seems to enlarge the query to much. I also tried other statements like nested queries or joins, but it seems that they have the same problem.</p> <p>Does anybody else has observed such a strange behavior of sqlite? And the much more important question: what can I do to make this query work on Android 2.3.3 with a near equal runtime?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload