Alert only when syslog message received multiple times

As a quick update and reminder for future me, I have spent a while sharing my darkest secrets with ChatGPT and it informs me that it is possible to reduce this query to a single run, however it presently only works in MySQL 8+ proper, MariaDB has a small shortfall in this feature which complains about duplicate column names when you do:

WITH results as (
  < normal alert query>
)
SELECT * FROM results WHERE (SELECT count(*) FROM results) > 1;

It’s likely in the near future this will work on MariaDB, or someone will jag the MariaDB format required: Comparison of Window Functions & CTEs in MySQL 8 vs MariaDB - Webyog

Needless to say, this is pushing SQL to the point where few understand it, it’s product and version sensitive - and being verbose and obvious as per the first attempt possibly has some merit if it isn’t causing any resource starvation.

1 Like