dbTalk Databases Forums  

speed of queries

comp.databases.postgresql comp.databases.postgresql


Discuss speed of queries in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pet
 
Posts: n/a

Default speed of queries - 08-05-2009 , 02:20 AM






Hello everyone!

What are the techniques for searching large tables without index
(SELECT id FROM big_table WHERE name LIKE '%search%'). With index,
queries are usually fast enough, but queries as above are to slow.

Regards, Pet

Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: speed of queries - 08-05-2009 , 03:00 AM






Pet wrote:
Quote:
What are the techniques for searching large tables without index
(SELECT id FROM big_table WHERE name LIKE '%search%'). With index,
queries are usually fast enough, but queries as above are to slow.
This is not possible; the only thing I can think of is a full text
search, but this is not what you have in mind:
You could find "I wonder who searches for entries like this", but not
"No research will ever locate this entry".

http://www.postgresql.org/docs/curre...extsearch.html

Yours,
Laurenz Albe

Reply With Quote
  #3  
Old   
Pet
 
Posts: n/a

Default Re: speed of queries - 08-05-2009 , 03:29 AM



On 5 Aug., 10:00, "Laurenz Albe" <inv... (AT) spam (DOT) to.invalid> wrote:
Quote:
Pet wrote:
What are the techniques for searching large tables without index
(SELECT id FROM big_table WHERE name LIKE '%search%'). With index,
queries are usually fast enough, but queries as above are to slow.

Hi Laurenz!
Thanks for your reply! I think full text search is in many cases
sufficient and if nothing found, I could fire slowest query then.

What about matching for chars with accent?
If someone search for Andre Rene how can I match to André René? Or
L'Ambre to Ambre or vice versa?
Will full text do that?

Quote:
This is not possible; the only thing I can think of is a full text
search, but this is not what you have in mind:
You could find "I wonder who searches for entries like this", but not
"No research will ever locate this entry".

http://www.postgresql.org/docs/curre...extsearch.html

Yours,
Laurenz Albe

Reply With Quote
  #4  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: speed of queries - 08-05-2009 , 11:37 AM



Pet wrote:
Quote:
Thanks for your reply! I think full text search is in many cases
sufficient and if nothing found, I could fire slowest query then.
Hmmm - doesn't that mean that if there is no match, you will
always run a query that does a full table scan?
Are you sure that you would like that?

Quote:
What about matching for chars with accent?
If someone search for Andre Rene how can I match to André René? Or
L'Ambre to Ambre or vice versa?
Will full text do that?
Not always.

I don't know very much about PostgreSQL's full text search, but
my research has shown that it depends on the dictionary in use.

For "normal" words, PostgreSQL uses a "Snowball dictionary"
by default, which performs "stemming" (linguistic normalization).

The German Snowball stemmer, for example, will convert an
Umlaut like "ü" to the base character "u", while no such
conversion is performed on "é" by the French Snowball stemmer.

You can create your own dictionaries, but I don't know if
you are willing to get that deeply involved
(http://snowball.tartarus.org/).

Yours,
Laurenz Albe

Reply With Quote
  #5  
Old   
Pet
 
Posts: n/a

Default Re: speed of queries - 08-05-2009 , 12:24 PM



On 5 Aug., 18:37, "Laurenz Albe" <inv... (AT) spam (DOT) to.invalid> wrote:
Quote:
Pet wrote:
Thanks for your reply! I think full text search is in many cases
sufficient and if nothing found, I could fire slowest query then.

Hmmm - doesn't that mean that if there is no match, you will
always run a query that does a full table scan?
Ok, it is not often the case.

Quote:
Are you sure that you would like that?
That's why I'm asking here.

Quote:
What about matching for chars with accent?
If someone search for Andre Rene how can I match to André René? Or
L'Ambre to Ambre or vice versa?
Will full text do that?

Not always.

I don't know very much about PostgreSQL's full text search, but
my research has shown that it depends on the dictionary in use.

For "normal" words, PostgreSQL uses a "Snowball dictionary"
by default, which performs "stemming" (linguistic normalization).

The German Snowball stemmer, for example, will convert an
Umlaut like "ü" to the base character "u", while no such
conversion is performed on "é" by the French Snowball stemmer.

You can create your own dictionaries, but I don't know if
you are willing to get that deeply involved
(http://snowball.tartarus.org/).
I see. Currently I do conversion to ASCII with python, works fine so
far for any chars

Pet

Quote:
Yours,
Laurenz Albe

Reply With Quote
  #6  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: speed of queries - 08-06-2009 , 05:29 AM



Pet wrote:
[Full text search]

Quote:
What about matching for chars with accent?
If someone search for Andre Rene how can I match to André René? Or
L'Ambre to Ambre or vice versa?
Will full text do that?

Not always.

I see. Currently I do conversion to ASCII with python, works fine so
far for any chars
Sure, if you write a PL/Python function that does the conversion,
you can simply use that in a trigger that populates the "tsvector"
column which you index for full text search.

Then, if you process the query string in a similar way,
it should work fine.

Yours,
Laurenz Albe

Reply With Quote
  #7  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: speed of queries - 08-19-2009 , 02:06 AM



Pet wrote:
Quote:
Thanks for your reply! I think full text search is in many cases
sufficient and if nothing found, I could fire slowest query then.

What about matching for chars with accent?
If someone search for Andre Rene how can I match to André René? Or
L'Ambre to Ambre or vice versa?
Will full text do that?
For the record: Teodor Sigaev has committed an "unaccent" contrib
for version 8.5 that will provide a dictionary and a function that
removes accents.

Yours,
Laurenz Albe

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.