简体   繁体   English

cronjobs mysql 表从其他表的连接更新

[英]cronjobs mysql table update from join of other tables

I have 1 master table that contains the data fetched from the join of other 3 tables.我有 1 个主表,其中包含从其他 3 个表的连接中获取的数据。 Those three tables are updated very frequently.I want to schedule a cron job that will change only those rows That were updated in those three tables.这三个表更新非常频繁。我想安排一个 cron 作业,该作业只会更改这三个表中更新的那些行。

One way is to delete the master table and populate it again by running the sql query.一种方法是删除主表并通过运行 sql 查询再次填充它。 But that is not efficient when I have to run the cronjob every 15 minutes and the number of rows in tables are in hundreds of thousands.但是,当我必须每 15 分钟运行一次 cronjob 并且表中的行数达到数十万时,这效率不高。

PS I am using php,mysql and cronjobs PS 我正在使用 php、mysql 和 cronjobs

Create a view joining the 3 tables.创建一个连接 3 个表的视图。 It would avoid creating any table and updating it every time the other tables are updated.它将避免创建任何表并在每次更新其他表时更新它。

Can you manipulate the table data in MySQL itself .If possible you can use triggers so that when any of the table data is updated, your master table will also be automatically updated.你能在 MySQL 本身中操作表数据吗?如果可能,你可以使用触发器,这样当任何表数据更新时,你的主表也会自动更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM