Search Postgresql Archives

Re: Regex query not using index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Postgres User" <postgres.developer@xxxxxxxxx> writes:
> My users are developers and the goal was to accept a simple
> comma-delimited list of string values as a function's input parameter.
>  The function would then parse this input param into a valid regex
> expression.

Why are you fixated on this being a regex?  If you aren't actually
trying to expose regex capabilities to the users, you'll just be having
to suppress a bunch of strange behaviors for special characters.

ISTM that the best solution is to use an array-of-text parameter,
along the lines of

	where name = any (array['Smith', 'Jones', ...])

For what you're doing, you'd not actually want the array[] syntax,
it would look more like

	where name = any ('{Smith,Jones}'::text[])

This should optimize into an indexscan in 8.2 or later.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux