Re: Using regexp from table has unpredictable poor performance

Поиск
Список
Период
Сортировка
От Justin Pryzby
Тема Re: Using regexp from table has unpredictable poor performance
Дата
Msg-id 20210825210500.GF10479@telsasoft.com
обсуждение исходный текст
Ответ на Using regexp from table has unpredictable poor performance  (Jack Christensen <jack@jncsoftware.com>)
Ответы Re: Using regexp from table has unpredictable poor performance  (Jack Christensen <jack@jncsoftware.com>)
Список pgsql-performance
On Wed, Aug 25, 2021 at 11:47:43AM -0500, Jack Christensen wrote:
> I have items that need to be categorized by user defined matching rules.
> Trusted users can create rules that include regular expressions. I've
> reduced the problem to this example.

> I use the following query to find matches:
> 
> select r.id, i.id
> from items i
>   join matching_rules r on i.name ~ r.name_matches;
> 
> When there are few rules the query runs quickly. But as the number of rules
> increases the runtime often increases at a greater than linear rate.

Maybe it's because the REs are cached by RE_compile_and_cache(), but if you
loop over the REs in the inner loop, then the caching is ineffecive.

Maybe you can force it to join with REs on the outer loop by writing it as:
| rules LEFT JOIN items WHERE rules.id IS NOT NULL,
..to improve performance, or at least test that theory.

-- 
Justin



В списке pgsql-performance по дате отправления:

Предыдущее
От: Jack Christensen
Дата:
Сообщение: Using regexp from table has unpredictable poor performance
Следующее
От: Jack Christensen
Дата:
Сообщение: Re: Using regexp from table has unpredictable poor performance