In my query I want find rows that match one of many LIKE operators. I know 3 ways of doing that but only one of them can use index.
Lets start with table:
You can create a trigram index that will support your query.
For that you need the pg_trgm
extension; run the following as superuser:
CREATE EXTENSION pg_trgm;
Then you can create a GIN index:
CREATE INDEX ON dir USING gin (path gin_trgm_ops);
This index can be used with your second and third approach, so it should do the trick for you.
With short patterns like the one in your examples, the index will not be very effective.
You can also use a GiST index, that will probably be smaller, but slower to search.
Note that you can use that index also with patterns that start with %
.