To select the maximum number of events to store in the database, and for how long to retain those events, go to System Settings > Object Data Store Settings in System Manager. Here, you can also enable similarity search caching.
WARNING: Using high limits may lead to unintended mass data deletion and increased system load. It is recommended to start with smaller limits and verify the results before executing larger operations.