Background
I have a composite index defined on a SQLAlchemy object, say:
class Shirt(Base):
__tablename__ = 'shirt'
id = Column(Integer, primary_key=True)
size = Column(String(32)) # e.g. small, medium large
color = Column(String(32)) # e.g. blue, red, white
Index('color_size', Shirt.size, Shirt.color)
Question
I'd now like to do a search for small and red shirts, taking advantage of the color_size composite index.
How do I write this query?
Would the use of and_() automatically take advantage of the index?
For example:
results = Shirt.query.filter( and_(Shirt.size=='small', Shirt.color=='red') ).all()