Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Worthwhile optimisation of position()?


  • From: Thomas Hallgren <thomas(at)tada(dot)se>
  • To: Thomas Hallgren <thomas(at)tada(dot)se>
  • Cc: Tim Allen <tim(at)proximity(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
  • Subject: Re: Worthwhile optimisation of position()?
  • Date: Fri, 24 Mar 2006 08:19:11 +0100
  • Message-id: <44239D6F(dot)6010409(at)tada(dot)se>

Thomas Hallgren wrote:
Tom Lane wrote:
Tim Allen <tim(at)proximity(dot)com(dot)au> writes:
Thomas Hallgren wrote:
The position function must look for 'ch' everywhere in the string so there's no way it can use an index.

I think the '= 0' bit is what Chris was suggesting could be the basis for an optimisation.

Yeah.  AFAICS the transformation Chris suggested is valid.  I'm really
dubious that it's worth expending planner cycles to look for it though.
LIKE is something that everybody and his brother uses, but who uses this
position()=0 locution?

            regards, tom lane
The documentation says: position('om' in 'Thomas') == 3 so i assumed that the returned index was 1-based and that a zero meant 'not found'. If I'm wrong ,perhaps the docs need to be updated?


The docs are correct so my initial point was correct. "position('ch' in user) = 0" is equivalent to "user NOT LIKE '%ch%'" and there's no way you can index that.

Regards,
Thomas Hallgren




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group