-2

I have MySQL database, and program in C# and winforms. It will run on few PC's over the lan network. I want to know if theres a way to check if theres changes in database without doing request each second.

Example: Admin will delete record from database, on workers pc I want to refresh list automatically.

zcoder
  • 50
  • 8
  • Dunno, on SQL Server you have `SqlDependency` which you can register to and alerts you to table changes. – Charlieface Jan 31 '21 at 14:42
  • @Charlieface i don't see something like that in my project but i found this [link](https://www.devart.com/dotconnect/mysql/docs/Devart.Data.MySql~Devart.Data.MySql.MySqlDependency.html) do you think this could work? – zcoder Jan 31 '21 at 14:46
  • You where not the first one to ask this: [Is there a way to 'listen' for a database event and update a page in real time?](https://stackoverflow.com/questions/6471879/is-there-a-way-to-listen-for-a-database-event-and-update-a-page-in-real-time) – Luuk Jan 31 '21 at 14:47
  • @Luuk but it's for JavaScript – zcoder Jan 31 '21 at 14:49
  • Sounds good, just check the performance implications on very large tables – Charlieface Jan 31 '21 at 14:51
  • @zcoder: And? It is also possible to do AJAX from Javascript... (see [this](https://stackoverflow.com/questions/496128/is-sajax-dead-what-to-replace-with/601538)) – Luuk Jan 31 '21 at 14:55
  • Possible duplicate of https://stackoverflow.com/questions/51292906/sqldependency-on-a-mariadb-mysql-database/51293221 – Bradley Grainger Jan 31 '21 at 19:17

1 Answers1

0

Don't worry about the performance of polling. With a suitable INDEX, MySQL can handle 100 polls/second -- regardless of dataset size.

Let's see SHOW CREATE TABLE and the tentative SELECT to perform the "poll"; I may have further tips.

Also, let's see the admin's query that needs to 'trigger' the workers into action. Surely the admin can do something simple to cause that. Doing a checksum of a table is terribly heavyweight.

You should consider the admin action to be encoded in a Stored Procedure, thereby separating the polling mechanism from the admin action.

JavaScript can use AJAX to do an INSERT (or call a Stored proc).

This mantra may apply: "Don't queue it, just do it." That is, the admin/javascript action can call an application program (PHP/Java/VB/whatever) to actually do the action, no need for queuing. (Please provide more details so we can discuss whether this might be the real solution.)

Rick James
  • 135,179
  • 13
  • 127
  • 222