We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

This is what makes newsfeed slow help to fix? | Forum

Topic location: Forum home » Support » General Questions
Marcus
Marcus Jan 9 '20

After some time digging into it looks like I have found what makes newsfeed slow....


Bellow is the query. I am not sure why do you have to inner join twise in same table...


Can someone please expaplin so i can find anoter way to dothat case obiusly current code aint working its slow as hell...


$query = 'SELECT COUNT(DISTINCT action.id) FROM ' . $this->getTableName() . ' action
                    INNER JOIN ' . $activityDao->getTableName() . ' activity ON action.id = activity.actionId
                    LEFT JOIN ' . $activityDao->getTableName() . ' pactivity ON activity.actionId = pactivity.actionId
                        AND (pactivity.status=:s AND pactivity.activityType=:ac AND pactivity.privacy!=:peb AND pactivity.visibility & :v)
                    ' . $queryParts["join"] . '

                    WHERE ' . $queryParts["where"] . ' AND pactivity.id IS NULL AND activity.status=:s AND activity.activityType=:ac AND activity.privacy=:peb AND activity.visibility & :v';





What is the purpose of doing this....


INNER JOIN ' . $activityDao->getTableName() . ' activity ON action.id = activity.actionId


INNER JOIN ' . $activityDao->getTableName() . ' cactivity ON action.id = cactivity.actionId

AppXprt
AppXprt Jan 9 '20
Looks like it's processing the feed purely with SQL based on each individual feed setting like activity type, status and privacy / visibility settings.


You might find another way, but with that current method, it is purely based on your database speed and capabilities and not that of the web server (or PHP for that matter.)


Your best solution might just be to increase your database resources / specs if possible.

Marcus
Marcus Jan 9 '20
Thanks buddy. My server 2 cpus and 4gb of ram.

Its index and dashboard that's slow not profile which has similar query. 

I might have to drop some checks from query like privacy etc... 
AppXprt
AppXprt Mar 25 '21
LoL no this is an issue with the design of that SQL statement.