How to deal with id gap when your query is like from id > XX to id < XXX
I aaume you want to extend the range of your search so it returns 50 rows even if there are gaps. Then you can use this:

SELECT TOP (50)
    id, name, address city
FROM table_name
WHERE id &gt; 5000000
  AND deleted_at IS NULL
ORDER BY id ;


A partial index on (id) WHERE (deleted_at IS NULL) would improve efficiency.