Solve this sql query

Manish Goyal

Manish Goyal

@manish-r2Hoep Oct 16, 2024
Below is a situation

I have two database table

1: Posts

2: Recent Watched

Now What I want is whenever user visits a certain post of mine, then it will make a new entry into recently watched table, through which i can see recently watched posts

Now The Problem is If my website hits reaches more than 200 k, then this table will be filled with no of records and ultimately will make my database very heavy

Now what I want is to delete the records from this table when it reaches certain limit automatically without any manual interference

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • The_Small_k

    The_Small_k

    @the-small-k Sep 15, 2013

    A database trigger will do the work for you😛. Which will execute the query on database event(like every time when count(row) in my table reach 30 it will delete 10 records from it)👍.