There are many ways to do this, but given that potential CM is rare, here is an example that just tries to avoid these rare rows:
sage: foo = set(db.ec_curvedata.search({'cm': {'$ne': 0}}, 'id'))
2023-07-11 09:06:50,616 - Search iterator for ec_curvedata {'cm': {'$ne': 0}} required a total of 2.7196309566497803s
2023-07-11 09:06:50,616 - Search iterator for ec_curvedata {'cm': {'$ne': 0}} required a total of 2.7196309566497803s
sage: m = db.ec_curvedata.max('id')
sage: bar = [elt for elt in [ZZ.random_element(m) for _ in range(3000)] if elt not in foo]
sage: len(bar)
2996
sage: data = list(db.ec_curvedata.search({'id': {'$in': bar[:2900]}}, 'lmfdb_label'))