From 71a009e03cb9f5b34efb9b096ee75939d633904c Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Thu, 1 Feb 2024 13:29:31 +0100 Subject: [PATCH] Add index on DateTime fields. --- api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.py b/api.py index 2c1c80b..525d2b8 100644 --- a/api.py +++ b/api.py @@ -60,7 +60,7 @@ ns_integer_metric = api.namespace('integer_metric/', description='Integer metric class Stock(db.Model): __tablename__ = "Stock" id = db.Column(db.Integer, primary_key=True, autoincrement=True) - time = db.Column(db.DateTime, nullable=False) + time = db.Column(db.DateTime, index=True, nullable=False) price = db.Column(db.Float, nullable=False) volume = db.Column(db.Integer, nullable=False) metric = db.Column(db.String(10), index=True, nullable=False) @@ -68,14 +68,14 @@ class Stock(db.Model): class Float_metric(db.Model): __tablename__ = "Float_metric" id = db.Column(db.Integer, primary_key=True, autoincrement=True) - time = db.Column(db.DateTime, nullable=False) + time = db.Column(db.DateTime, index=True, nullable=False) value = db.Column(db.Float, nullable=False) metric = db.Column(db.String(50), index=True, nullable=False) class Integer_metric(db.Model): __tablename__ = "Integer_metric" id = db.Column(db.Integer, primary_key=True, autoincrement=True) - time = db.Column(db.DateTime, nullable=False) + time = db.Column(db.DateTime, index=True, nullable=False) value = db.Column(db.Integer, nullable=False) metric = db.Column(db.String(50), index=True, nullable=False)