[SQL] Index Usage and Running Times by FullTextSearch with prefix matching

2013-06-13 Thread rawi
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 ('o,p,f,j,z,j', to_tsvector('o,p,f,j,z,j');

Re: [SQL] Index Usage and Running Times by FullTextSearch with prefix matching

2013-06-13 Thread Tom Lane
rawi only4...@web.de writes: 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. FWIW, I get fairly decent performance for cases like this in HEAD (at least with a GIN

[SQL] Re: Index Usage and Running Times by FullTextSearch with prefix matching

2013-06-13 Thread rawi
Tom Lane-2 wrote FWIW, I get fairly decent performance for cases like this in HEAD (at least with a GIN index; GIST seems much less able to do well with short prefixes). What PG version are you testing? Thank you Tom, I'm testing on PG 9.1 on UbuntuServer 12.10, 64bit I'll update to 9.2 the

[SQL] Re: Index Usage and Running Times by FullTextSearch with prefix matching

2013-06-13 Thread rawi
Tom Lane-2 wrote FWIW, I get fairly decent performance for cases like this in HEAD (at least with a GIN index; GIST seems much less able to do well with short prefixes). Short or long prefixes seem to be equaly unfavorable. Even with the full length of the words, but queried as prefix I get a

[SQL] Select clause in JOIN statement

2013-06-13 Thread JORGE MALDONADO
Is it valid to specify a SELECT statement as part of a JOIN clause? For example: SELECT table1.f1, table1.f2 FROM table1 INNER JOIN (SELECT table2.f1, table2.f2 FROM table2) table_aux ON table1.f1 = table_aux.f1 Respectfully, Jorge Maldonado

Re: [SQL] Select clause in JOIN statement

2013-06-13 Thread Luca Vernini
It works. Also consider views. Just used this on a my db: SELECT * FROM tblcus_customer INNER JOIN ( SELECT * FROM tblcus_customer_status WHERE status_id 0) AS b ON tblcus_customer.status = b.status_id You can even join with a function result. Regards, Luca. 2013/6/14 JORGE MALDONADO