Is it possible to add a COUNT() collumn in a mapper object?

So with every product object I would like to have the number of related stockproducts added. But Instead of doing it with eagerload and returning len(orderproducts), I would like to have it done with the COUNT function in SQL for performance reasons.

Thanks Koen

Like this:

products = Table('products', engine,
    Column('id', Integer, Sequence('products_id_seq',optional=False), primary_key=True),
    Column('code', Unicode(255), nullable=False),
 Column('price', Numeric, nullable=False))

stockproducts = Table('stockproducts', engine,
    Column('id', Integer, Sequence('stockproducts_id_seq',optional=False), primary_key=True),
 Column('product_id', Integer, ForeignKey("products.id"), nullable=False),
 Column('serial', Unicode(50), nullable=True))

class Product(object):
assign_mapper(Product, products)

class StockProduct(object):
assign_mapper(StockProduct, stockproducts)