Indexing very similar character varying field in postgres
What a terrible query! Consider using different software.
The only thing that could help are trigram indexes on both columns:
CREATE EXTENSION pg_trgm;

CREATE INDEX ON upload_file USING gin ((name::text) gin_trgm_ops);
CREATE INDEX ON upload_file USING gin ((id::text) gin_trgm_ops);

Then you might get two bitmap index scans and a &quot;bitmap or&quot;.
If not, the condition is probably not selective enough, and a sequential scan is the most efficient way to handle it.