| From: | David Johnston <polobo(at)yahoo(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: expression index not used within function |
| Date: | 2013-11-13 23:29:18 |
| Message-ID: | 1384385358798-5778242.post@n5.nabble.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
LPlateAndy wrote
> When i call SELECT * FROM _function(IN TEXT) it is very slow on my WHERE
> clause using LIKE($1||'%') but (run in error), very fast when LIKE('some
> text'||'%')
The index cannot be used for LIKE ($1 || '%') because there is no way the
planner can guarantee the value of $1 isn't something like "%mid" which
would resolve to "LIKE (%mid%)" which is a mid-string search which the index
will not help with.
If you place a constant at the front of the like pattern it can use the
index to get into the region with the matching prefix.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/expression-index-not-used-within-function-tp5778236p5778242.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sergey Burladyan | 2013-11-13 23:53:17 | Re: freeze cannot be finished |
| Previous Message | LPlateAndy | 2013-11-13 23:22:06 | Re: expression index not used within function |