diff --git a/migrations/008_delta.sql b/migrations/008_delta.sql index 14fbc21..8a1518b 100644 --- a/migrations/008_delta.sql +++ b/migrations/008_delta.sql @@ -1,2 +1,9 @@ ALTER TABLE stacktach_instanceexists ADD `audit_period_beginning` numeric(20, 6); -ALTER TABLE stacktach_instanceexists ADD `audit_period_ending` numeric(20, 6); \ No newline at end of file +ALTER TABLE stacktach_instanceexists ADD `audit_period_ending` numeric(20, 6); +CREATE INDEX `stacktach_instanceusage_987c9676` ON `stacktach_instanceusage` (`launched_at`); +CREATE INDEX `stacktach_instancedeletes_987c9676` ON `stacktach_instancedeletes` (`launched_at`); +CREATE INDEX `stacktach_instancedeletes_738c7e64` ON `stacktach_instancedeletes` (`deleted_at`); +CREATE INDEX `stacktach_instanceexists_987c9676` ON `stacktach_instanceexists` (`launched_at`); +CREATE INDEX `stacktach_instanceexists_738c7e64` ON `stacktach_instanceexists` (`deleted_at`); +CREATE INDEX `stacktach_instanceexists_23564986` ON `stacktach_instanceexists` (`audit_period_beginning`); +CREATE INDEX `stacktach_instanceexists_b891fefb` ON `stacktach_instanceexists` (`audit_period_ending`); \ No newline at end of file diff --git a/migrations/008_exists_audit_period_indexes.sql b/migrations/008_exists_audit_period_indexes.sql index 8807871..56611e4 100644 --- a/migrations/008_exists_audit_period_indexes.sql +++ b/migrations/008_exists_audit_period_indexes.sql @@ -19,11 +19,18 @@ CREATE INDEX `stacktach_lifecycle_9b2555fd` ON `stacktach_lifecycle` (`last_stat CREATE INDEX `stacktach_lifecycle_67421a0e` ON `stacktach_lifecycle` (`last_task_state`); CREATE INDEX `stacktach_lifecycle_dcf9e5f3` ON `stacktach_lifecycle` (`last_raw_id`); CREATE INDEX `stacktach_instanceusage_888b756a` ON `stacktach_instanceusage` (`instance`); +CREATE INDEX `stacktach_instanceusage_987c9676` ON `stacktach_instanceusage` (`launched_at`); CREATE INDEX `stacktach_instanceusage_792812e8` ON `stacktach_instanceusage` (`request_id`); CREATE INDEX `stacktach_instanceusage_f321fd7` ON `stacktach_instanceusage` (`instance_type_id`); CREATE INDEX `stacktach_instancedeletes_888b756a` ON `stacktach_instancedeletes` (`instance`); +CREATE INDEX `stacktach_instancedeletes_987c9676` ON `stacktach_instancedeletes` (`launched_at`); +CREATE INDEX `stacktach_instancedeletes_738c7e64` ON `stacktach_instancedeletes` (`deleted_at`); CREATE INDEX `stacktach_instancedeletes_365c3a01` ON `stacktach_instancedeletes` (`raw_id`); CREATE INDEX `stacktach_instanceexists_888b756a` ON `stacktach_instanceexists` (`instance`); +CREATE INDEX `stacktach_instanceexists_987c9676` ON `stacktach_instanceexists` (`launched_at`); +CREATE INDEX `stacktach_instanceexists_738c7e64` ON `stacktach_instanceexists` (`deleted_at`); +CREATE INDEX `stacktach_instanceexists_23564986` ON `stacktach_instanceexists` (`audit_period_beginning`); +CREATE INDEX `stacktach_instanceexists_b891fefb` ON `stacktach_instanceexists` (`audit_period_ending`); CREATE INDEX `stacktach_instanceexists_38373776` ON `stacktach_instanceexists` (`message_id`); CREATE INDEX `stacktach_instanceexists_f321fd7` ON `stacktach_instanceexists` (`instance_type_id`); CREATE INDEX `stacktach_instanceexists_c9ad71dd` ON `stacktach_instanceexists` (`status`); diff --git a/stacktach/models.py b/stacktach/models.py index b63f5f2..98306ee 100644 --- a/stacktach/models.py +++ b/stacktach/models.py @@ -79,7 +79,7 @@ class InstanceUsage(models.Model): instance = models.CharField(max_length=50, null=True, blank=True, db_index=True) launched_at = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, db_index=True) request_id = models.CharField(max_length=50, null=True, blank=True, db_index=True) instance_type_id = models.CharField(max_length=50, @@ -92,9 +92,9 @@ class InstanceDeletes(models.Model): instance = models.CharField(max_length=50, null=True, blank=True, db_index=True) launched_at = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, db_index=True) deleted_at = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, db_index=True) raw = models.ForeignKey(RawData, null=True) @@ -112,13 +112,14 @@ class InstanceExists(models.Model): instance = models.CharField(max_length=50, null=True, blank=True, db_index=True) launched_at = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, db_index=True) deleted_at = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, db_index=True) audit_period_beginning = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, + db_index=True) audit_period_ending = models.DecimalField(null=True, max_digits=20, - decimal_places=6) + decimal_places=6, db_index=True) message_id = models.CharField(max_length=50, null=True, blank=True, db_index=True) instance_type_id = models.CharField(max_length=50,