Re: Can Postgres beat Oracle for regexp_count?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Can Postgres beat Oracle for regexp_count?
Дата
Msg-id CAHyXU0wUM56XEqq1MVhML=XV7+wTio1UwC6eJ+RxGWdmaJTJ8g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Can Postgres beat Oracle for regexp_count?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Wed, Feb 2, 2022 at 4:26 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > Given we don't have a regexp_count function this isn't surprising...
>
> FYI, it's there in HEAD.
>
> In the meantime, you could possibly do something like
>
> =# select count(*) from regexp_matches('My High Street', '([A-Z][a-z]+[\s])', 'g');
>  count
> -------
>      2
> (1 row)

alternate version:
postgres=# select array_upper(regexp_split_to_array('My High Street My
High Street', 'My High Street'), 1) - 1;
 ?column?
──────────
        2

can help to slide this into complex queries a little bit easier by
avoiding the aggregation :-).

merlin



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

Предыдущее
От: A Shaposhnikov
Дата:
Сообщение: Re: increasing effective_cache_size slows down join queries by a factor of 4000x
Следующее
От: rob stan
Дата:
Сообщение: Postgres Version Upgrade to 14.1 error