Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Pavel Stehule
2010/3/25 Louis-David Mitterrand : > On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote: >> Petru Ghita writes: >> > "..immediately replaced with the function value" doesn't mean that the >> > results of a previously evaluated function for the same parameters are >> > stored and reused? >> >

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Louis-David Mitterrand
On Thu, Mar 25, 2010 at 08:27:27AM +0100, Pavel Stehule wrote: > 2010/3/25 Louis-David Mitterrand : > > On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote: > >> Petru Ghita writes: > >> > "..immediately replaced with the function value" doesn't mean that the > >> > results of a previously ev

[SQL] Week to date function

2010-03-25 Thread Ireneusz Pluta
Hello, is there any standard function, or a concise solution based on set of them, returning a set of dates included in a week of given year and week number? I ended up with creating my own function as in the example below, but I am curious if I am not opening an open door. Thanks Irek. C

Re: [SQL] Week to date function

2010-03-25 Thread Sergey Konoplev
On 25 March 2010 12:25, Ireneusz Pluta wrote: > Hello, > > is there any standard function, or a concise solution based on set of them, > returning a set of dates included in a week of given year and week number? > I ended up with creating my own function as in the example below, but I am > curious

[SQL] Capacity planning.

2010-03-25 Thread David Harel
Hi, Any way to get transaction count from the postgres daemon or any log? Also where can I find docs that can help me make a capacity plan for max 100,000 clients making around 200 transactions a day each. -- Regards. David Harel, == Home office +972 77 76

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Tom Lane
Louis-David Mitterrand writes: > Hmm, that's interesting. So for simple functions (like my example) it is > better to write them in plain sql? And in that case no 'immutable' flag > is necessary? If it's just a simple SQL expression, then yes write it as a SQL function. The planner can "inline"

Re: [SQL] Plpgsql: Iterating through a string of parameters

2010-03-25 Thread Leif Biberg Kristensen
On Thursday 25. March 2010 16.16.53 Leif Biberg Kristensen wrote: > I'm struggling with how to make plpgsql iterate through a list of numbers > input as a text string, eg. "1438 2656 973 4208". I figure that I can use the > regexp_split_to_array() function to make an array of the string, but can

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Greg Stark
On Thu, Mar 25, 2010 at 2:35 PM, Tom Lane wrote: > When you're intending to have a SQL function be inlined, it's probably > best not to mark it as either IMMUTABLE or STRICT --- that doesn't buy > anything and it can complicate matters as to whether inlining is legal. I'm confused, I thought it w

[SQL] Plpgsql: Iterating through a string of parameters

2010-03-25 Thread Leif Biberg Kristensen
I'm struggling with how to make plpgsql iterate through a list of numbers input as a text string, eg. "1438 2656 973 4208". I figure that I can use the regexp_split_to_array() function to make an array of the string, but can I iterate through an array with eg. a FOR loop? regards, -- Leif Bibe

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Pavel Stehule
2010/3/25 Louis-David Mitterrand : > On Thu, Mar 25, 2010 at 08:27:27AM +0100, Pavel Stehule wrote: >> 2010/3/25 Louis-David Mitterrand : >> > On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote: >> >> Petru Ghita writes: >> >> > "..immediately replaced with the function value" doesn't mean t

Re: [SQL] Does IMMUTABLE property propagate?

2010-03-25 Thread Tom Lane
Greg Stark writes: > On Thu, Mar 25, 2010 at 2:35 PM, Tom Lane wrote: >> When you're intending to have a SQL function be inlined, it's probably >> best not to mark it as either IMMUTABLE or STRICT --- that doesn't buy >> anything and it can complicate matters as to whether inlining is legal. > I

[SQL] Help me with this multi-table query

2010-03-25 Thread Nilesh Govindarajan
Hi, I want to find out the userid, nodecount and comment count of the userid. I'm going wrong somewhere. Check my SQL Code- select u.uid, count(n.nid) nc , count(c.cid) cc from users u left join node n on ( n.uid = u.uid ) left join comments c on ( c.uid = u.uid ) group by u.uid having u.uid

[SQL] Help with reg_exp

2010-03-25 Thread John Gage
[I mistakenly used the wrong Subject line initially with this post] In going through the arcana of string functions, I have come across the following series of selects that contain, for me, a mysterious "$re$". -- return all matches from regexp SELECT regexp_matches(' foobarbequebaz', $re$(bar)(b

[SQL] Dollar quoted strings

2010-03-25 Thread John Gage
Thanks very much for this. I am using 8.4.2. This query works as you describe in pgAdmin. I had tried it in the SquirrelSQL client, which is where it produced the result. Obviously, this is a SquirrelSQL problem at least in part. What does mean? Thanks again for directing me to the doc's

Re: [SQL] Dollar quoted strings

2010-03-25 Thread Robert Manning
Hi John, The type code 2003 indicates an SQL99 column type of ARRAY, which is not currently supported for rendering/editing. Here is the feature request for SQuirreL SQL Client to track this feature: https://sourceforge.net/tracker/?func=detail&aid=2972937&group_id=28383&atid=393417 Rob On Wed

[SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Snyder, James
Hello I'm using PostgreSQL (8.4.701) and Java (jdbc, postgresql-8.4-701.jdbc4.jar) to connect to the database. My question is: what is the SQL syntax for PostgreSQL to achieve the following: I want to receive the rowcount along with the rest of a result set. For example, let's say the following

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Thomas Kellerer
Snyder, James wrote on 25.03.2010 22:33: I’m using PostgreSQL (8.4.701) There is no such version. The current version is 8.4.3 On a side note, Oracle allows the following syntax to achieve the above: select count(*) over () as ROWCOUNT , first_name from people The same syntax will work on

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
Hi, Is this what you are trying to do? postgres=# select * from (select count(*) from people ) p, (select firstname from people)p2; count | firstname ---+--- 5 | Mary 5 | Mary 5 | John 5 | John 5 | Jacob (5 rows) I do not know about the performance impact of s

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
Hi, I don't think so. Oracle - SQL> select count(*) over () as ROWCOUNT , first_name from people; ROWCOUNT FIRST_NAME -- - --- 6 Mary 6 Mary 6 John 6 John

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread A. Kretschmer
In response to Jayadevan M : > Hi, > I don't think so. > Oracle - > SQL> select count(*) over () as ROWCOUNT , first_name from people; > > ROWCOUNT FIRST_NAME > -- > - > --- > 6 Mary

Re: [SQL] Help me with this multi-table query

2010-03-25 Thread A. Kretschmer
In response to Nilesh Govindarajan : > Hi, > > I want to find out the userid, nodecount and comment count of the userid. > > I'm going wrong somewhere. > > Check my SQL Code- Check my example: test=*# select * from u; id 1 2 3 (3 rows) test=*# select * from n; uid - 1 1

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread Jayadevan M
Hi, >It works, but you should use a recent version: >test=*# select count(1) over (), i from foo; > count | i >---+ > 8 | 1 > 8 | 2 > 8 | 3 > 8 | 6 > 8 | 7 > 8 | 9 > 8 | 13 > 8 | 14 >(8 rows) > test=*# select version(); >