Implement an efficient search algorithm to filter through a large, in-memory dataset based on dynamic user queries.
Implement search_records(records, query). Each record is a dictionary with unique id, status, category, and integer price fields. A query may contain status, category, min_price, and max_price; omitted fields impose no restriction. Return matching record IDs in their original dataset order, with price bounds inclusive.
def search_records(records, query):