grep -f keyword data query

From: Hiroyuki Sato <hiroysato(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: grep -f keyword data query
Date: 2015-12-27 09:53:17
Message-ID: CA+Tq-RqW_yryEt_ntPyT2xckYY5v=dum2xLg8mNL9yM0cJuP+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

I would like to create the query like the following.
It work well, but extreme slow.
Is it possible to improve this query like the command ``grep -f keyword
data``?

What kind of Index should I create on url_lists table?

Detail
https://gist.github.com/hiroyuki-sato/574b8ea5d9396e455d60

SELECT
u.url
FROM
url_lists u,
keywords k
WHERE
u.url @~ k.url
AND
k.name = 'esc_url';

Explain output.

Nested Loop (cost=0.45..1570856063.28 rows=57122000000 width=57)
-> Index Scan using ix_name_keywords on keywords k (cost=0.28..221.78
rows=5000 width=30)
Index Cond: ((name)::text = 'esc_url'::text)
-> Index Only Scan using ix_url_url_lists on url_lists u
(cost=0.17..199927.17 rows=11424400 width=57)
Index Cond: (url @~ k.url)

Best regards.

--
Hiroyuki Sato.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2015-12-27 10:23:00 Re: grep -f keyword data query
Previous Message Jony Cohen 2015-12-27 08:00:00 Re: efficient math vector operations on arrays