AJAX for content impressions

Hello webmasters,

I have a website about memes and I want to update the database each time the user scrolls down.
I have no problem when I make a few requests to the database, but what if I want to do a lot of requests in a large database?
I recently had to refactor my code to exclude some code that is important just for the sake of performance.
Is there any way around it? How does Facebook do it?