Add index on DateTime fields.

This commit is contained in:
yohan 2024-02-01 13:29:31 +01:00
parent 3e906314f2
commit 71a009e03c

6
api.py
View File

@ -60,7 +60,7 @@ ns_integer_metric = api.namespace('integer_metric/', description='Integer metric
class Stock(db.Model): class Stock(db.Model):
__tablename__ = "Stock" __tablename__ = "Stock"
id = db.Column(db.Integer, primary_key=True, autoincrement=True) 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) price = db.Column(db.Float, nullable=False)
volume = db.Column(db.Integer, nullable=False) volume = db.Column(db.Integer, nullable=False)
metric = db.Column(db.String(10), index=True, 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): class Float_metric(db.Model):
__tablename__ = "Float_metric" __tablename__ = "Float_metric"
id = db.Column(db.Integer, primary_key=True, autoincrement=True) 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) value = db.Column(db.Float, nullable=False)
metric = db.Column(db.String(50), index=True, nullable=False) metric = db.Column(db.String(50), index=True, nullable=False)
class Integer_metric(db.Model): class Integer_metric(db.Model):
__tablename__ = "Integer_metric" __tablename__ = "Integer_metric"
id = db.Column(db.Integer, primary_key=True, autoincrement=True) 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) value = db.Column(db.Integer, nullable=False)
metric = db.Column(db.String(50), index=True, nullable=False) metric = db.Column(db.String(50), index=True, nullable=False)