SQL/Drizzle Where Query Search Optimization

Hi, originally I wanted a fuzzy search but now I just wanted to look how far I can get with just a where query.

I have a few concerns with the reads this query causes to the database.

Especially I want to know if I can stop if I already have 5 via the name or if you generally have some read and performance optimizations.

ctx.db.query.city.findMany({
        limit: 5,
        where: (users, { like, or }) =>
          or(
            or(
              like(users.name, input.name + "%"),
              like(users.name, "%" + input.name),
            ),
            or(
              like(users.germanName, input.name + "%"),
              like(users.germanName, "%" + input.name),
            ),
            or(
              like(users.region, input.name + "%"),
              like(users.region, "%" + input.name),
            ),
          ),
Was this page helpful?