监听数据库插入并向Android设备发送推送通知

i want to send push notification to all my devices when there is an insert into table. i successfully developped a php script to send push notification.Now, i want to know how to detect the insert into one of my table. i'm asking for ideas.NB: leater this script will be executed in a cron mode.

There are two solutions I can think of:

  • Make a thread that does a select after an x amount of time.
  • Use Sockets, so on the server side it sends a message to the client after a successful insert into the database.