What is the proper way to update a value after update or insert?
Hello everyone! So I have 2 tables. Table 1 is Profiles and table 2 is Videos. Videos table has a foreign key to the profiles table based on the user_id. On the profiles table I have a column which is called avg_views which basically should be the avarage views of that profile based on the views column on the videos table.
So I have a trigger
But it seems to cause statement_timeout errors.
I have many more queries like the one above that update different columns. My question is: is this properly written? How can I do this in a better and optimal way?
Thanks in advance!
So I have a trigger
But it seems to cause statement_timeout errors.
I have many more queries like the one above that update different columns. My question is: is this properly written? How can I do this in a better and optimal way?
Thanks in advance!