Jaxel
Well-known member
So I have a column in my table, that is a blob of usergroup ids... ex:
I would like to search this table, for results in which the user's group's match this column.
Currently I am doing it was follows:
This is working, really well too. And on my test forum, it seems to have no effect on performance... but depending on the number of groups a user belongs to, this could add a ton of
Is there a better way to do this? Also, would the performance be affected by the 10,000 rows of the main table, or the 15 rows of the joined category table?
["2","3","5","9"]
I would like to search this table, for results in which the user's group's match this column.
Currently I am doing it was follows:
PHP:
$visitor = \XF::visitor();
$whereOr = [
[' Category.category_groups', 'LIKE', '%"'.$visitor->user_group_id.'"%'],
];
foreach ($visitor->secondary_group_ids AS $group)
{
$whereOr[] = ['Category.category_groups', 'LIKE', '%"'.$group.'"%'];
}
$finder->whereOr($whereOr);
This is working, really well too. And on my test forum, it seems to have no effect on performance... but depending on the number of groups a user belongs to, this could add a ton of
%LIKE%
clauses to the query. While I am querying a table that has 10,000+ rows, the joined category table that it's connect to only has about 15 rows. It's not unfathomable that this would have a significant effect on performance in a table that has over a million rows.Is there a better way to do this? Also, would the performance be affected by the 10,000 rows of the main table, or the 15 rows of the joined category table?