def prune_existing_records(db, records_to_be_saved):
    """
    Return a list of records which are not already present in the db from the input list
    """
    ok_records = []
    fetch_dates = set([rec['fetch_date'] for rec in records_to_be_saved])
    pre_existing = set()
    for fd in fetch_dates:
        stocks = db.asx_prices.distinct('asx_code', {'fetch_date': fd})
        for stock in stocks:
            pre_existing.add("{}-{}".format(stock, fd))
    for rec in records_to_be_saved:
        key = "{}-{}".format(rec['asx_code'], rec['fetch_date'])
        if key not in pre_existing:
            ok_records.append(rec)
    return ok_records