Querying Best Practices?

Just want to discuss query best practices.
const userAccount = await db.query.accounts.findFirst({
    where: eq(accounts.id, userId),
    with: {
      activeProfile: {
        with: {
          savedShows: {
            where: eq(myShows.id, input.id),
            limit: 1, // Does using limit matter here? It should speed up query right?
          },
        },
      },
    },
  })

And since I only need the nested relations
const userAccount = await db.query.accounts.findFirst({
    columns: {}, // Would this matter? Does it speed up queries? It would transfer less data but is that all?
    where: eq(accounts.id, userId),
    with: {
      activeProfile: {
        with: {
          savedShows: {
            where: eq(myShows.id, input.id),
            limit: 1, 
          },
        },
      },
    },
  })
Was this page helpful?