kopia lustrzana https://github.com/glidernet/ogn-python
Huge speedup (factor 30+) for update_receiver and update_device due to multi-column indices
rodzic
61939913b5
commit
150491a830
|
@ -1,4 +1,4 @@
|
||||||
from sqlalchemy import Column, String, Integer, Float, Boolean, SmallInteger, ForeignKey
|
from sqlalchemy import Column, String, Integer, Float, Boolean, SmallInteger, ForeignKey, Index
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .beacon import Beacon
|
from .beacon import Beacon
|
||||||
|
@ -42,12 +42,16 @@ class AircraftBeacon(Beacon):
|
||||||
distance = Column(Float)
|
distance = Column(Float)
|
||||||
|
|
||||||
# Relations
|
# Relations
|
||||||
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'), index=True)
|
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'))
|
||||||
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
||||||
|
|
||||||
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'), index=True)
|
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'))
|
||||||
device = relationship('Device', foreign_keys=[device_id])
|
device = relationship('Device', foreign_keys=[device_id])
|
||||||
|
|
||||||
|
# Multi-column indices
|
||||||
|
Index('ix_aircraft_beacon_receiver_id_receiver_name', 'receiver_id', 'receiver_name')
|
||||||
|
Index('ix_aircraft_beacon_device_id_address', 'device_id', 'address')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<AircraftBeacon %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
return "<AircraftBeacon %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
||||||
self.address_type,
|
self.address_type,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from sqlalchemy import Column, Float, String, Integer, SmallInteger, ForeignKey
|
from sqlalchemy import Column, Float, String, Integer, SmallInteger, ForeignKey, Index
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .beacon import Beacon
|
from .beacon import Beacon
|
||||||
|
@ -34,9 +34,12 @@ class ReceiverBeacon(Beacon):
|
||||||
status = Column(SmallInteger, index=True)
|
status = Column(SmallInteger, index=True)
|
||||||
|
|
||||||
# Relations
|
# Relations
|
||||||
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'), index=True)
|
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'))
|
||||||
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
receiver = relationship('Receiver', foreign_keys=[receiver_id])
|
||||||
|
|
||||||
|
# Multi-column indices
|
||||||
|
Index('ix_receiver_beacon_receiver_id_name', 'receiver_id', 'name')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<ReceiverBeacon %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
return "<ReceiverBeacon %s: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
||||||
self.version,
|
self.version,
|
||||||
|
|
|
@ -15,5 +15,6 @@ class TestStringMethods(unittest.TestCase):
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
raise AssertionError(e)
|
raise AssertionError(e)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Ładowanie…
Reference in New Issue