3 ms·
I'm full stack so while I use pg plenty I'm not an expert .. but wouldn't creating a cache table that auto updates counts maybe automatically or on a schedule(
by gremlinsinc 5y ago
I'm full stack so while I use pg plenty I'm not an expert ..
but wouldn't creating a cache table that auto updates counts maybe automatically or on a schedule(if counts come fast and need locking) be a decent method?
then it's as simple as select count from counter_cache where table=posts and related_table=user and related_id=1... which would get all that users posts as a count...
I guess you could do similar with views or material views but I haven't used them much at all to know when to... really I'm in php/MySQL more than pg but have been dabbling with hasura and creating stored functions in some side projects...