Index Usage and Running Times by FullTextSearch with prefix matching

Поиск
Список
Период
Сортировка
От rawi
Тема Index Usage and Running Times by FullTextSearch with prefix matching
Дата
Msg-id 1371123556877-5759021.post@n5.nabble.com
обсуждение исходный текст
Ответы Re: Index Usage and Running Times by FullTextSearch with prefix matching  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hi

I tested the following:

CREATE TABLE t1
( id serial NOT NULL, a character varying(125), a_tsvector tsvector, CONSTRAINT t1_pkey PRIMARY KEY (id)
);

INSERT INTO t1 (a, a_tsvector) 
VALUES ('ooooo,ppppp,fffff,jjjjj,zzzzz,jjjjj',
to_tsvector('ooooo,ppppp,fffff,jjjjj,zzzzz,jjjjj');

CREATE INDEX a_tsvector_idx  ON t1 USING gin (a_tsvector);

(I have generated 900000 records with random words like this)

Now querying: normal full text search

SELECT count(a)
FROM t1
WHERE a_tsvector @@ to_tsquery('aaaaa & bbbbb & ccccc & ddddd')

(RESULT: count: 619)
Total query runtime: 353 ms.
Query Plan:
"Aggregate  (cost=6315.22..6315.23 rows=1 width=36)"
"  ->  Bitmap Heap Scan on t1  (cost=811.66..6311.46 rows=1504 width=36)"
"        Recheck Cond: (a_tsvector @@ to_tsquery('aaaaa & bbbbb & ccccc &
ddddd'::text))"
"        ->  Bitmap Index Scan on a_tsvector_idx  (cost=0.00..811.28
rows=1504 width=0)"
"              Index Cond: (a_tsvector @@ to_tsquery('aaaaa & bbbbb & ccccc
& ddddd'::text))"

And querying: FTS with prefix matching:

SELECT count(a)
FROM t1
WHERE a_tsvector @@ to_tsquery('aaa:* & b:* & c:* & d:*')

(RESULT: count: 619)
Total query runtime: 21266 ms.
Query Plan:
"Aggregate  (cost=804.02..804.03 rows=1 width=36)"
"  ->  Bitmap Heap Scan on t1  (cost=800.00..804.02 rows=1 width=36)"
"        Recheck Cond: (a_tsvector @@ to_tsquery('aaa:* & b:* & c:* &
d:*'::text))"
"        ->  Bitmap Index Scan on a_tsvector_idx  (cost=0.00..800.00 rows=1
width=0)"
"              Index Cond: (a_tsvector @@ to_tsquery('aaa:* & b:* & c:* &
d:*'::text))"

I don't understand the big query time difference, despite the explainig
index usage.
NOnetheless I'd like to simulate LIKE 'aaa%' with full text search. Would I
have a better sollution?

Many thanks in advance!

Rawi



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Index-Usage-and-Running-Times-by-FullTextSearch-with-prefix-matching-tp5759021.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



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

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: Advice with an insert query
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Index Usage and Running Times by FullTextSearch with prefix matching