Re: [SQL] Power cut and performance problem

2006-03-21 Thread Aftab Alam
unsubscribe Regards, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jeff Frost Sent: Tuesday, March 21, 2006 9:19 PM To: Daniel Caune Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Power cut and performance problem On Tue, 21 Mar 2006, Daniel Caune w

Re: [SQL] Power cut and performance problem

2006-03-21 Thread Aftab Alam
unsubscribe Regards, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Daniel Caune Sent: Tuesday, March 21, 2006 9:44 PM To: Jeff Frost Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Power cut and performance problem > > For example, the execution o

Re: [SQL] have you feel anything when you read this ?

2006-03-21 Thread Bruno Wolff III
On Mon, Mar 20, 2006 at 17:40:03 -0500, Tom Lane <[EMAIL PROTECTED]> wrote: > > Indeed. I wonder whether we shouldn't tweak the SQL string literal > parser to reject \000, because AFAICS that isn't going to do anything > useful for any datatype, and it leads to what are at best questionable > r

Re: [SQL] Using a parameter in Interval

2006-03-21 Thread Stephan Szabo
On Tue, 21 Mar 2006, Davidson, Robert wrote: > No matter how I try to concatenate, I can't seem to get a parameter to be > used by INTERVAL in a function: > > CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$ > BEGIN > RETURN current_date - INTERVAL (CAST(TrailingWeek

Re: [SQL] Using a parameter in Interval

2006-03-21 Thread Owen Jacobson
Here's one I used to convert an int to an interval in another project: CREATE OR REPLACE FUNCTION to_interval (sec INTEGER) RETURNS INTERVAL AS $$ BEGIN RETURN (sec || ' seconds')::INTERVAL; END; $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT; select to_interval (5); to_interval - 00:00:0

Re: [SQL] Using a parameter in Interval

2006-03-21 Thread Michael Glaesemann
On Mar 22, 2006, at 9:52 , Davidson, Robert wrote: ERROR: syntax error at or near "CAST" at character 34 QUERY: SELECT current_date - INTERVAL (CAST( $1 AS varchar) || ' weeks') CONTEXT: SQL statement in PL/PgSQL function "testing" near line 2 The generally recommended way is somethi

[SQL] Using a parameter in Interval

2006-03-21 Thread Davidson, Robert
Title: Using a parameter in Interval No matter how I try to concatenate, I can’t seem to get a parameter to be used by INTERVAL in a function: CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$ BEGIN     RETURN current_date - INTERVAL (CAST(TrailingWeeks AS varcha

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread Scott Marlowe
On Tue, 2006-03-21 at 08:58, [EMAIL PROTECTED] wrote: > Hello, > > I've got 2 tables, "url" (U), and "bookmark" (B), with "bookmark" pointing to > "url" via FK. > Somehow I ended up with some rows in B referencing non-existent rows in U. > This sounds super strange and dangerous to me, and it's n

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread Stephan Szabo
On Tue, 21 Mar 2006 [EMAIL PROTECTED] wrote: > I mistakenly swapped the tables in my email. Here they are, corrected: > > Table "url": > id SERIAL > CONSTRAINT pk_url_id PRIMARY KEY > > Table "bookmark": > url_id INTEGER >

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread ogjunk-pgjedan
Hi, I mistakenly swapped the tables in my email. Here they are, corrected: Table "url": id SERIAL CONSTRAINT pk_url_id PRIMARY KEY Table "bookmark": url_id INTEGER CONSTRAINT fk_url_id REFERENCES url

Re: [SQL] plpqsql and RETURN NEXT requires a LOOP?

2006-03-21 Thread Owen Jacobson
In general, to do anything useful with RETURN NEXT you need a loop. However, it doesn't need to be a loop over another resultset: you can do a computation in a loop, returning values as you go. Excuse the outlook-ism. -Owen -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PRO

[SQL] plpqsql and RETURN NEXT requires a LOOP?

2006-03-21 Thread Davidson, Robert
Title: plpqsql and RETURN NEXT requires a LOOP? From my reading of 36.7.1 Returning from a Function http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING it appears that RETURN NEXT in a plpgsql function requires you to loop through the

Re: [SQL] Power cut and performance problem

2006-03-21 Thread Daniel Caune
> > For example, the execution of the following query is fast as it used to > > be (gslog_event_id is the primary key on gslog_event): > > > > select max(gslog_event_id) from gslog_event; (=> Time: 0.773 ms) > > > > > > while the following query is really slow (several minutes): > > > > select m

[SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread ogjunk-pgjedan
Hello, I've got 2 tables, "url" (U), and "bookmark" (B), with "bookmark" pointing to "url" via FK. Somehow I ended up with some rows in B referencing non-existent rows in U. This sounds super strange and dangerous to me, and it's not clear to me how/why PG let this happen. I'm using 8.0.3. Here

Re: [SQL] Power cut and performance problem

2006-03-21 Thread Daniel Caune
> BTW, I didn't complete my first thought above, which was to ask when you > last > vacuumed the DB, but then I saw that you were running autovac, so that > wasn't > likely the problem. > > BTW, if the problem is actually a raid array that is rebuilding, it should > be > (hopefullY) fixed by tomor

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread Stephan Szabo
On Tue, 21 Mar 2006 [EMAIL PROTECTED] wrote: > I've got 2 tables, "url" (U), and "bookmark" (B), with "bookmark" pointing to > "url" via FK. That's not what your schema below has. Your fragment below has URL pointing to bookmark. > Somehow I ended up with some rows in B referencing non-existen

Re: [SQL] Power cut and performance problem

2006-03-21 Thread Jeff Frost
On Tue, 21 Mar 2006, Daniel Caune wrote: For example, the execution of the following query is fast as it used to be (gslog_event_id is the primary key on gslog_event): select max(gslog_event_id) from gslog_event; (=> Time: 0.773 ms) while the following query is really slow (several minutes)

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread Aftab Alam
delete my email from the list Regards, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 8:29 PM To: pgsql-sql@postgresql.org Subject: [SQL] Referential integrity broken (8.0.3), sub-select help Hello, I'v

Re: [SQL] Job queue, how would you implement this?

2006-03-21 Thread Achilleus Mantzios
O Alexis Paul Bertolini έγραψε στις Mar 21, 2006 : > Dear all, > > I have implemented a job queue table where various apps can add jobs to > the queue and other daemons then execute them. A basic producer-consumer > pattern. Each tuple in the queue has the basic info such as job to be > done,

[SQL] Job queue, how would you implement this?

2006-03-21 Thread Alexis Paul Bertolini
Dear all, I have implemented a job queue table where various apps can add jobs to the queue and other daemons then execute them. A basic producer-consumer pattern. Each tuple in the queue has the basic info such as job to be done, when it should be done, who should do it, a flag marking it com

Re: [SQL] have you feel anything when you read this ?

2006-03-21 Thread Eugene E.
Scott Marlowe wrote: On Mon, 2006-03-20 at 02:06, Eugene E. wrote: http://dev.mysql.com/doc/refman/5.0/en/news-5-0-19.html --- cut --- mysql no longer terminates data value display when it encounters a NUL byte. Instead, it displays NUL bytes as spaces. (Bug #16859) --- cut --- Everyone he

Re: [SQL] have you feel anything when you read this ?

2006-03-21 Thread Eugene E.
PFC wrote: I wrote: the problem is: you'll get this four byte sequence '\000' _instead_ of NUL-byte anyway. You wrote: Your client library should take care of escaping and de-escaping. We both agree as you see. Then i am asking: WHY should a client take care of de-escaping ? Why no

Re: [SQL] Update counter when row SELECT'd ... ?

2006-03-21 Thread PFC
On Tue, 21 Mar 2006 04:33:22 +0100, Daniel CAUNE <[EMAIL PROTECTED]> wrote: I have a simple table: name, url, counter I want to be able to do: SELECT * FROM table ORDER BY counter limit 5; But, I want counter to be incremented by 1 *if* the row is included in that 5 ... so that those 5 basic