add indexes

This commit is contained in:
Milos Kozak 2021-05-13 14:11:38 +02:00
parent bcd74897d4
commit 2657830f0d
20 changed files with 3731 additions and 20 deletions

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ import androidx.room.TypeConverters
import info.nightscout.androidaps.database.daos.*
import info.nightscout.androidaps.database.entities.*
const val DATABASE_VERSION = 18
const val DATABASE_VERSION = 20
@Database(version = DATABASE_VERSION,
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,

View file

@ -18,7 +18,16 @@ import java.util.*
entity = Bolus::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("isValid"),
Index("temporaryId"),
Index("pumpId"),
Index("pumpSerial"),
Index("pumpType"),
Index("referenceId"),
Index("timestamp")
])
data class Bolus(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -12,7 +12,12 @@ import java.util.TimeZone
entity = BolusCalculatorResult::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("referenceId"),
Index("timestamp"),
Index("id"),
Index("isValid")
])
data class BolusCalculatorResult(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -16,7 +16,13 @@ import java.util.*
entity = Carbs::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("isValid"),
Index("nightscoutId"),
Index("referenceId"),
Index("timestamp")
])
data class Carbs(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -11,7 +11,11 @@ import java.util.*
@Entity(tableName = TABLE_DEVICE_STATUS,
foreignKeys = [],
indices = [Index("timestamp")])
indices = [
Index("id"),
Index("nightscoutId"),
Index("timestamp")
])
data class DeviceStatus(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,

View file

@ -19,7 +19,12 @@ import java.util.*
entity = EffectiveProfileSwitch::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("referenceId"),
Index("timestamp"),
Index("isValid")
])
data class EffectiveProfileSwitch(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,
@ -45,7 +50,7 @@ data class EffectiveProfileSwitch(
var originalEnd: Long,
@Embedded
var insulinConfiguration: InsulinConfiguration
) : TraceableDBEntry, DBEntryWithTime{
) : TraceableDBEntry, DBEntryWithTime {
enum class GlucoseUnit {
MGDL,

View file

@ -16,7 +16,16 @@ import java.util.*
entity = ExtendedBolus::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("isValid"),
Index("endId"),
Index("pumpSerial"),
Index("pumpId"),
Index("pumpType"),
Index("referenceId"),
Index("timestamp")
])
data class ExtendedBolus(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -14,7 +14,12 @@ import info.nightscout.androidaps.database.interfaces.TraceableDBEntry
entity = Food::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId")])
indices = [
Index("id"),
Index("nightscoutId"),
Index("referenceId"),
Index("isValid")
])
data class Food(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -13,7 +13,13 @@ import java.util.TimeZone
entity = GlucoseValue::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("nightscoutId"),
Index("sourceSensor"),
Index("referenceId"),
Index("timestamp")
])
data class GlucoseValue(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -19,7 +19,13 @@ import java.util.*
entity = ProfileSwitch::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("referenceId"),
Index("timestamp"),
Index("isValid"),
Index("id"),
Index("nightscoutId")
])
data class ProfileSwitch(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,
@ -47,6 +53,7 @@ data class ProfileSwitch(
enum class GlucoseUnit {
MGDL,
MMOL;
companion object {}
companion object
}
}

View file

@ -16,7 +16,17 @@ import java.util.*
entity = TemporaryBasal::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("isValid"),
Index("nightscoutId"),
Index("pumpType"),
Index("endId"),
Index("pumpSerial"),
Index("temporaryId"),
Index("referenceId"),
Index("timestamp")
])
data class TemporaryBasal(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -17,7 +17,13 @@ import java.util.*
entity = TemporaryTarget::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("isValid"),
Index("nightscoutId"),
Index("referenceId"),
Index("timestamp")
])
data class TemporaryTarget(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -17,7 +17,14 @@ import java.util.*
entity = TherapyEvent::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("type"),
Index("nightscoutId"),
Index("isValid"),
Index("referenceId"),
Index("timestamp")
])
data class TherapyEvent(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -16,7 +16,15 @@ import java.util.*
entity = TotalDailyDose::class,
parentColumns = ["id"],
childColumns = ["referenceId"])],
indices = [Index("referenceId"), Index("timestamp")])
indices = [
Index("id"),
Index("pumpId"),
Index("pumpType"),
Index("pumpSerial"),
Index("isValid"),
Index("referenceId"),
Index("timestamp")
])
data class TotalDailyDose(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0,

View file

@ -1,13 +1,18 @@
package info.nightscout.androidaps.database.entities
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import info.nightscout.androidaps.database.TABLE_USER_ENTRY
import info.nightscout.androidaps.database.interfaces.DBEntry
import info.nightscout.androidaps.database.interfaces.DBEntryWithTime
import java.util.*
@Entity(tableName = TABLE_USER_ENTRY)
@Entity(tableName = TABLE_USER_ENTRY,
indices = [
Index("source"),
Index("timestamp")
])
data class UserEntry(
@PrimaryKey(autoGenerate = true)
override var id: Long = 0L,

View file

@ -0,0 +1,187 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "391daa1e25629bafef27e6247e788e74",
"entities": [
{
"tableName": "insightBolusIDs",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `pumpSerial` TEXT, `bolusID` INTEGER, `startID` INTEGER, `endID` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "pumpSerial",
"columnName": "pumpSerial",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "bolusID",
"columnName": "bolusID",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "startID",
"columnName": "startID",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "endID",
"columnName": "endID",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_insightBolusIDs_bolusID",
"unique": false,
"columnNames": [
"bolusID"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightBolusIDs_bolusID` ON `${TABLE_NAME}` (`bolusID`)"
},
{
"name": "index_insightBolusIDs_pumpSerial",
"unique": false,
"columnNames": [
"pumpSerial"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightBolusIDs_pumpSerial` ON `${TABLE_NAME}` (`pumpSerial`)"
},
{
"name": "index_insightBolusIDs_timestamp",
"unique": false,
"columnNames": [
"timestamp"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightBolusIDs_timestamp` ON `${TABLE_NAME}` (`timestamp`)"
}
],
"foreignKeys": []
},
{
"tableName": "insightHistoryOffsets",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`pumpSerial` TEXT NOT NULL, `offset` INTEGER NOT NULL, PRIMARY KEY(`pumpSerial`))",
"fields": [
{
"fieldPath": "pumpSerial",
"columnName": "pumpSerial",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "offset",
"columnName": "offset",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"pumpSerial"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_insightHistoryOffsets_pumpSerial",
"unique": false,
"columnNames": [
"pumpSerial"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightHistoryOffsets_pumpSerial` ON `${TABLE_NAME}` (`pumpSerial`)"
}
],
"foreignKeys": []
},
{
"tableName": "insightPumpIDs",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timestamp` INTEGER NOT NULL, `eventType` TEXT NOT NULL, `pumpSerial` TEXT, `eventID` INTEGER NOT NULL, PRIMARY KEY(`eventID`))",
"fields": [
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "eventType",
"columnName": "eventType",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "pumpSerial",
"columnName": "pumpSerial",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "eventID",
"columnName": "eventID",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"eventID"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_insightPumpIDs_timestamp",
"unique": false,
"columnNames": [
"timestamp"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightPumpIDs_timestamp` ON `${TABLE_NAME}` (`timestamp`)"
},
{
"name": "index_insightPumpIDs_pumpSerial",
"unique": false,
"columnNames": [
"pumpSerial"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightPumpIDs_pumpSerial` ON `${TABLE_NAME}` (`pumpSerial`)"
},
{
"name": "index_insightPumpIDs_eventType",
"unique": false,
"columnNames": [
"eventType"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_insightPumpIDs_eventType` ON `${TABLE_NAME}` (`eventType`)"
}
],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '391daa1e25629bafef27e6247e788e74')"
]
}
}

View file

@ -5,7 +5,11 @@ import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(tableName = DATABASE_INSIGHT_BOLUS_IDS,
indices = [Index("bolusID")])
indices = [
Index("bolusID"),
Index("pumpSerial"),
Index("timestamp")
])
data class InsightBolusID(
var timestamp: Long,
val pumpSerial: String? = null,

View file

@ -22,7 +22,7 @@ abstract class InsightDatabase : RoomDatabase() {
companion object {
const val VERSION = 1
const val VERSION = 2
fun build(context: Context) =
Room.databaseBuilder(

View file

@ -5,7 +5,11 @@ import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(tableName = DATABASE_INSIGHT_PUMP_IDS,
indices = [Index("timestamp")])
indices = [
Index("timestamp"),
Index("pumpSerial"),
Index("eventType")
])
data class InsightPumpID(
var timestamp: Long,
var eventType: EventType = EventType.None,