I have a sql query that runs super fast, around one second, when not using variables, like:
WHERE id BETWEEN 5461094 and 5461097
But when I
Actually, it was answered very well, I just write here a workaround as it worked for me:
Create a stored procedure with the SQL
WHERE id BETWEEN @firstId and @lastId
After then call the stored proc with parameters @firstId and @lastId and it will speed up. I still not 100% why it is working, but it works.