Re: String manipulation - Mailing list pgsql-novice

From Tom Lane
Subject Re: String manipulation
Date
Msg-id 17030.1059441673@sss.pgh.pa.us
Whole thread Raw
In response to Re: String manipulation  (Joe Conway <mail@joeconway.com>)
List pgsql-novice
Joe Conway <mail@joeconway.com> writes:
> SELECT substring(path from position(' ' in path) + 1) FROM (SELECT
> split_part( path, ':', 2 ) AS path FROM paths) AS ss;

> I could be wrong but I was thinking it would be more efficient to only
> calculate the function once.

Actually, the only thing you saved was writing out the split_part call
twice --- when the planner flattens the sub-select it expands each
reference to a sub-select output, so the split_part ends up getting
evaluated twice anyway.  But the notational savings can be useful.

            regards, tom lane

pgsql-novice by date:

Previous
From: Joe Conway
Date:
Subject: Re: String manipulation
Next
From: "psql novice"
Date:
Subject: Retrieving NULL records