Cache for lookup tables: Make it faster and usable for views

Post Reply
patrick.nehls2
User
Posts: 16

Cache for lookup tables: Make it faster and usable for views

Post by patrick.nehls2 »

In order to decide whether a cache is supposed to be used for a lookup table PhpMaker is running a (very slow) COUNT() .
This COUNT(
) might lead to two errors:

  1. COUNT(*) on large tables might run into timeout on PHP
  2. COUNT(*) on MySQL views produces: ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

Instead of having a compatible SQL COUNT() for all database flavors, I suggest to have an individual counting as described in these MySQL examples:

SELECT COUNT(*) FROM (SELECT 1 FROM table_or_view LIMIT ${cache limit}+1) x;

Other database surely have a similar functionality (such as TOP in MS-SQL).

As I ran into error #2 my solution was to disabled the cache.


Post Reply