Hi Nobu,

This is I'm using by AsyncTask and query text strings or pieces of text
from database.

* This is my Query..*

 pupils = (ArrayList<Pupil>)new Pupil()
            .list("Grade like ? AND Classroom like ? AND Active = 1 AND
CurrentMonthStatus != ?",
                    new String[] {
                            String.valueOf(gradeId),
String.valueOf(classroom),

Character.toString(AppConstants.PUPIL_IN_WAITLIST)
                    });


*above list moved to below adapter then it's goes to below method..*

public List<?> list(String selection, String[] selectionArgs) {

        return DBConnector.dbAdapter.list(this, null, selection,
selectionArgs, null, null, null);
    }

*This is the method to render the data from db..*

public ArrayList<Object> list(Object object, String[] columns, String
selection,
            String[] selectionArgs, String groupBy, String having, String
orderBy) {
        try {

            ArrayList<Object> results = new ArrayList<Object>();

            Class<?> clazz = Class.forName(object.getClass().getName());

            String tableName = getDbTableName(object);

            open();
            Cursor cursor = db.query(tableName, columns, selection,
selectionArgs, groupBy, having,
                    orderBy);

            if (cursor.getCount() > 0) {
                while (cursor.moveToNext()) {
                    results.add(getObjectFromCursor(cursor, clazz));
                }
                Log.d("results ", ""+results);
            }
            cursor.close();

            return results;

        } catch (SQLiteConstraintException e) {
            AppLogger.e(e);
            return null;
        } catch (ClassNotFoundException e) {
            AppLogger.e(e);
            return null;
        }
    }

  Please let me know how to make indexes,  optimize my query and optimize
execution time??

Please any body help me on this..


Thanks,
Vamshi.



On Sat, Jun 8, 2013 at 8:32 AM, Nobu Games <[email protected]> wrote:

> Hi Vamshi,
>
> I got a hunch here, so I need to ask you first if you are querying that
> data from a background thread (using AsyncTask) for example. If you don't
> do that the user interface gets noticeably blocked / unresponsive for a
> moment making your activity appear "slow". By querying the data from a
> background thread you can make your activity *appear* to be "faster",
> because the UI is still able to respond to touch events and so on.
>
> If this is not the issue then it might be your database or the query
> itself.
>
> So here a few questions for you in return:
>
> - Do you query text strings or pieces of text from your database? This can
> be really really slow because SQLite usually needs to go through all
> records and scan them for matching the strings. That's especially a big
> problem with "LIKE" conditions. You can dramatically boost your database
> string search performance using the FTS3 
> extension<http://www.sqlite.org/fts3.html>.
> Which comes at a cost of course, the database gets much bigger, but in my
> opinion that's well worth it.
>
> - Do you use (complicated) table joins? Maybe you can optimize your query
>
> - What is / what are the columns that get queried most often? It might be
> possible that you can create an indexes for these (but use them sparingly)
>
> Maybe you want to post the SQL table creation code of your database tables
> and your query code.
>
>
>
> On Thursday, June 6, 2013 12:22:43 PM UTC-5, vamshi ch wrote:
>>
>>  Hi All,
>>
>>    I have an Activity with contain data and when i click the data then it
>> moves to another activity in background it renders the list of data from
>> database(sqlite) and it consuming most of the time. so i need to modify and
>> reduce the execution and rendering time. Please let me know what are
>> approaches should i use to implement.
>>
>> Please help me on this.
>>
>>
>> Thanks,
>> Vamshi.
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to