sql >> Base de Datos >  >> RDS >> SQLite

Registrar tiempo de consulta en SQLite en Android

Sqlite para Android tiene un soporte integrado para eso.

Desde aquí:

/**
 * Controls the printing of wall-clock time taken to execute SQL statements
 * as they are executed.
 *
 * Enable using "adb shell setprop log.tag.SQLiteTime VERBOSE".
 */
public static final boolean DEBUG_SQL_TIME =
        Log.isLoggable("SQLiteTime", Log.VERBOSE);

Por lo tanto, para habilitar el seguimiento del tiempo de ejecución, ejecute:

adb shell setprop log.tag.SQLiteTime VERBOSE

Tendrá que reiniciar su aplicación para volver a cargar la nueva configuración**. Inmediatamente después, comenzará a ver estos registros en logcat:

02-14 12:27:00.457 11936-12137/osom.info.dbtest I/Database:elapsedTime4Sql|/data/data/osom.info.dbtest/databases/test.db|1.000ms|UPDATE TestTable SET key=? DONDE _id=1

** A veces esto no será suficiente, así que ejecute adb shell stop y adb shell start .

Para dejar de imprimir estos registros, reinicie el dispositivo (esta propiedad no persiste entre reinicios) o establezca la propiedad en un nivel de registro superior, es decir:

adb shell setprop log.tag.SQLiteTime ERROR