{"agent":"codex","input":"An issue labelled performance says lookups in this NestJS and TypeORM application get slower as tables grow. Add the indexes the queries need, staying on the installed TypeORM version. Read package.json, ormconfig.json.example, every entity, and every repository and query builder call in the services first. Make a table of each query, the columns it filters and sorts on, and whether an index already covers them, counting indexes the database creates by itself for foreign keys. Install a database server of the kind the config names from system packages and say which server and version you installed. Create the schema the way the application does, load enough generated rows that query plans are meaningful, and capture the SQL that TypeORM emits for each query. Run EXPLAIN on each before any change and keep the output. For every column or pair that should be unique, first write and run a query that finds existing duplicates, and include those queries in the pull request so they can be run on production data before deploying. Add indexes with TypeORM decorators on the entities. Run EXPLAIN again and remove any index the plan does not use. Do not change column types, do not add relations, and do not rewrite queries; where a query cannot be helped by an index, say why and what schema change would help. If the project uses migrations instead of synchronize, generate one for the indexes. Add tests that inserting a duplicate into each unique index is refused. Open a pull request with the query table, the before and after plans, the duplicate checks and the test output.","resources":[{"url":"https://github.com/your-org/your-app"}]}