Skip to content
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

Phonegap/Cordova pre populated SQLite data retrieve too slow #127

Closed
athimannil opened this issue Aug 27, 2014 · 2 comments
Closed

Phonegap/Cordova pre populated SQLite data retrieve too slow #127

athimannil opened this issue Aug 27, 2014 · 2 comments

Comments

@athimannil
Copy link

The Phonegap/Cordova project using https://github.com/brodysoft/Cordova-SQLitePlugin for using SQLite. There is minor changes made in MainViewController.m to use pre-populated databse (however it might not effect the problem).

The database detecting very well here is the databaase detecting code

function onDeviceReady() {
    db = window.sqlitePlugin.openDatabase({name: "database.db"});
    db.transaction(queryDB, errorCB);

    function queryDB(tx) {
        console.log("started");
        tx.executeSql("select * from user_info", [], function(tx, res) {
            console.log("res.rows.length: " + res.rows.length);
        });
    }

    function errorCB(err) {
        console.log("Error processing SQL : "+err.message);
    }
}

Result

res.rows.length: 1

Here is the retrieving data code which takes about 10 sec to show result :(

function callMe (argument) {
    db.transaction(buttonqueryDB, buttonerrorCB);
    function buttonqueryDB(transaction) {
        console.log("going to query");
        transaction.executeSql('SELECT * FROM home_word', [], function(transaction, result) {
            console.log("total itemes " + result.rows.length);
            if (result != null && result.rows != null) {
                for (var i = 0; i < 10; i++) {
                    var row = result.rows.item(i);
                    console.log("this result : " +row.word);
                }
            }

        });
    }
    function buttonerrorCB(err) {
        console.log("Error processing SQL : "+err.message);
    }
}

The result above query is searching from 1,25,2100 rows. Testing on iOS emulator takes about 5sec and testing on iPhone takes 10sec 😞
The going to query shows quickly and query result display takes about 10sec

@brody4hire
Copy link

Internally, the plugin has to convert the query result data to JSON before sending to the Javascript, then the Cordova JS decodes the JSON result data. Needs to be documented in the readme. Batch query API may be able to help solve this.

brody4hire pushed a commit that referenced this issue Apr 21, 2015
… with app name (ref: #243); possible stability issue with SockJS client (ref: #196); retrieve of large data set can be too slow due to JSON (ref: #127); memory issue when adding large numbers of records (ref: #18)
@brody4hire
Copy link

This is now documented in README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants