How simplify/optimize a search of keywords in two tables at the same time?
The default Postgresql configuration will be used.


The default PostgreSQL configuration is meant to be adequate for smallish servers.  If you are worried about scalability, which you seem to be, then restricting yourself to using the default configuration is going to be a poor plan.


  WHERE p.name ILIKE ANY(potential_parts)


You are probably going to want a trgm_ops index on p.name, and similarly on T.name

You might also need to add user-space code which prevents people from searching on things of less than 3 or 4 characters.


  We can consider that each table will have more than a million of row.


Make a million rows of dummy data, and see what happens.  No use speculating when you can just do it.