Update join relationship of orders table to selectin
closes #6791 by slightly improving performance in this area.
This commit is contained in:
parent
e6172a68d7
commit
ee0e59157c
@ -1144,7 +1144,8 @@ class Trade(_DECL_BASE, LocalTrade):
|
|||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
orders = relationship("Order", order_by="Order.id", cascade="all, delete-orphan", lazy="joined")
|
orders = relationship("Order", order_by="Order.id", cascade="all, delete-orphan",
|
||||||
|
lazy="selectin", innerjoin=True)
|
||||||
|
|
||||||
exchange = Column(String(25), nullable=False)
|
exchange = Column(String(25), nullable=False)
|
||||||
pair = Column(String(25), nullable=False, index=True)
|
pair = Column(String(25), nullable=False, index=True)
|
||||||
|
@ -2197,15 +2197,16 @@ def test_get_trades__query(fee, is_short):
|
|||||||
# without orders there should be no join issued.
|
# without orders there should be no join issued.
|
||||||
query1 = Trade.get_trades([], include_orders=False)
|
query1 = Trade.get_trades([], include_orders=False)
|
||||||
|
|
||||||
assert "JOIN orders" in str(query)
|
# Empty "with-options -> default - selectin"
|
||||||
assert "JOIN orders" not in str(query1)
|
assert query._with_options == ()
|
||||||
|
assert query1._with_options != ()
|
||||||
|
|
||||||
create_mock_trades(fee, is_short)
|
create_mock_trades(fee, is_short)
|
||||||
query = Trade.get_trades([])
|
query = Trade.get_trades([])
|
||||||
query1 = Trade.get_trades([], include_orders=False)
|
query1 = Trade.get_trades([], include_orders=False)
|
||||||
|
|
||||||
assert "JOIN orders" in str(query)
|
assert query._with_options == ()
|
||||||
assert "JOIN orders" not in str(query1)
|
assert query1._with_options != ()
|
||||||
|
|
||||||
|
|
||||||
def test_get_trades_backtest():
|
def test_get_trades_backtest():
|
||||||
|
Loading…
Reference in New Issue
Block a user