Most efficient way to build a system that counts 'impessions' of listings

Hey all,

With one of our projects we have a dynamic diectory, this creates thousands of page variations with results.

We have page views being counted when a specific profile is viewed, however, i’d now like to introduce impressions when the results are displayed on page.

Initially the hyphothesis was easy to create this.

One new transaction type table that counts the record id, impression date etc.
Then on the actual record table, I have a simple integer that counts upwards.

When the page loads, and the paged DB Query returns the 15 results, my thought (and my current setup) was simply to repeat the paged query (the 15 results) - only the specific id, not the whole data returned and then have an ‘insert’ db query for the impressions table, and then an update query matching the record id and simply adding 1 to the records impressions number - all happening on the server side aligned with the results.

This is working fine.

However, the speed the page results return and display on the front end has slowed quite a lot.

So I was wondering if perhaps anyone had any other ideas that may improve the logic to achieve this, and importantly not impact performance ‘too much’. As it’s a directory listing results, with SEO being the primary goal - we need to maintain rapid page load.

Appreciate any input from anyone on the forum.

Community Page
Last updated: