indexing - postgresql full text search function syntax -


in postgres database have table table1 , column column1 type text. , created index column create index idx_column1 on table1 using gin (to_tsvector('english', column1));

question is, why when execute query

select * table1 to_tsvector('english', column1) @@ to_tsquery('searchedtext') 

index used, query index not used

select * table1 ts_match_vq(to_tsvector('english', column1),to_tsquery('searchedtext')) 

wild guess:

vector @@ query defined

create operator @@(   procedure = ts_match_vq,   leftarg = tsvector,   rightarg = tsquery,   commutator = @@,   restrict = tsmatchsel,   join = tsmatchjoinsel); 

looking @ tsmatchjoinsel there quite lot going on (don't ask me what, kind of c way beyond me....) if go through different functions, there calculations involved. when using ts_match_vq directly, bypass these calculations. that's why ts_match_vq never mentioned in docs , should use @@ since takes care of calling right functions , stuff goes it.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -