Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 47
Registered: ‎03-27-2010
My Device: Bold 9000
My Carrier: Rogers

Speeding up Google Gears Sqlite?

Hi,

 

I have a simple query that shows 20-30 rows of results but when its executed, it seems to take alot longer than I would expect - it takes 5 - 7 seconds some times. Does anybody know if this is a limitation with google gears and/or the blackberries? I have been testing this on both the blackberry 8900 and 9000 physical devices.

 

FYI - I am closing each 'execute' statement so no memory leaks are occuring. The table it is calling from has a total of 200 items and I have indexed it as well. I am also using explicit transactions when executing and retrieving my result sets (ie. 'Begin' and 'Commit')

 

Thanks ahead of time for the help.

 

-Dg

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

Hi Dg,

 

Have you put in some JavaScript Timers to see if it is the SQLite queries or the time it is taking to render the DOM change?  From my experience the time it takes to execute the SQLite queries is quite fast, but DOM manipulation can be a bit slower to render especially if there are lots of changes in the DOM.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Highlighted
Contributor
Posts: 47
Registered: ‎03-27-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

Hi Tim,

 

You're right. I put in some timers and the SQL query does run faster - the manipulation of the DOM is what's slowing the app down. I know this is a seperate topic from what I have started, do you know any ways of making the DOM work faster?

 

Thanks,

 

Dg

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

One thing you can try is to incrementally update the DOM.. For example, you can create a loop that when you are done processing the first X number of rows you exit the function by using a setTimeout() to then call a function to show the remaining rows.  Kind of like a recursive function that exits calls itself by using setTimeout() to ensure the current thread is exited.

 

Does that make sense?

 

Essentially the goal is to make smaller incremental DOM updates and then use setTimeout() to exit the current JavaScript thread so that those DOM updates are displayed.   

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 47
Registered: ‎03-27-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

Not really. Would you be able to provide me with a small code example so I can better understand?

 

Thank you

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

[ Edited ]

 

It would look something like:

 

 

var _myArray;
var _index;


function displayDetails() {

  for (var i = _index; i < _index + 10; i++) {
     if (i == _myArray.length - 1) return;

     // .... Perform DOM manipulation
  }
  _index = _index + 10;
  setTimeout("displayDetails()", 300);

}

 

Also check the speed class rating for your SD Card.  It will have a direct impact on SQLite read/write speeds.

 

http://en.wikipedia.org/wiki/Secure_Digital#Speed_Class_Rating

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 47
Registered: ‎03-27-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

That seems to have improved the performance! I'm going to continue testing to ensure that this method is a viable solution. Thank you!

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

Check out the following post where there's a valuable tip on how to increase write speed to the SQLite DB as well

 

http://supportforums.blackberry.com/t5/Web-Development/widget-gears-database-throughput/td-p/484557/...

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 47
Registered: ‎03-27-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

Hi Tim,

 

I seem to have discovered a problem. While adding the code setTimeout(doSomething(),10), it seems that if any action (ie. click on a button) is done while this thread is running in the background will cause the app AND blackberry to crash. I am unable to do anything at this point and the battery needs to be pulled to bring it back.

 

Do you know if there is a way to prevent this from happening?

 

Thanks

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Speeding up Google Gears Sqlite?

Hi drjg22,

 

We have uncovered a thread deadlock issue when using the focus based navigation mode and having the DOM update in a different thread.

 

We are very close to a solution.  I would suggest subscribing to the following thread to keep up to date with the latest news on this topic.

 

http://supportforums.blackberry.com/t5/Web-Development/Focus-based-navigation-hangs-device/m-p/49647...

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter