Re: [SQL] Porting from PL/SQL to PLPGSQL

2003-08-14 Thread Josh Berkus
Jomon, > 1)In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I > can't find a replacement for that in > PostGreSQL. PL/pgSQL currently does not handle exceptions at all. This is on the TODO list. > 2 Oracle have a function USERENV to get the user session >

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread SZŰCS Gábor
Dear Jonathan, Thanks for your will to help. It would be a bit difficult to clean up everything as much as possible (while keeping the problem) and send the skeleton. It looks like the A_AU trigger I mentioned solved the problem. Actually, the situation I painted is much much simplified compare

Re: [SQL] How to check: is some key referenced from sometable

2003-08-14 Thread eVl One
Hello, Bruno. You wrote 9 08 2003, 18:08:09: BWI> On Mon, Aug 04, 2003 at 11:17:56 +0300, BWI> [EMAIL PROTECTED] wrote: >> Please help. >> >> Need a boolean function which returns true if given key in table is >> referensed from another table(s). BWI> Use "exists" with a subselect. Something

Re: [SQL] How to check: is some key referenced from sometable

2003-08-14 Thread Bruno Wolff III
On Mon, Aug 04, 2003 at 11:17:56 +0300, [EMAIL PROTECTED] wrote: > Please help. > > Need a boolean function which returns true if given key in table is > referensed from another table(s). Use "exists" with a subselect. Something like: select exists(select 1 from table where table.key = 'value')

Re: [SQL] looking for empty fields

2003-08-14 Thread Jodi Kanter
Title: Viorel Thank you for responding and sorry to waste your time. I just realized my stupid mistake after sending the message! It was an integer field. Jodi Viorel Dragomir wrote:   - Original Message - From: JodiKanter

Re: [SQL] length of recordset read through a cursor

2003-08-14 Thread Knut P. Lehre
>> After declaring a cursor, one way of obtaining the length of the >resultset >> is to perform a "MOVE 0" and read the PQcmdStatus which returns a >"MOVE nn" >> where nn is the length of the resultset. (A negative MOVE can then be >used >> to allow starting to fetch records from the beginning of

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-14 Thread Benoît Bournon
we make a dump before ... and with a product pgmanager (ems tech) we do not show any foreign keys. But I think all of triggers of referenced table are not deleted. We recreate the schemas ... and now is running. How is it possible to identify Triggers with no referenced tables ? Stephan Sz

[SQL] (no subject)

2003-08-14 Thread A. Van Hook
We have been using 7.3.3 on several different applications and have discovered an anomaly. Backups are done nightly using "pg_dump --attribute-inserts -f att.dump.`dcode` spdb"; Dump files are used to restore and test. This test method has been used successfully on all previous versions. However

Re: [SQL] Using rowtype as function argument

2003-08-14 Thread Tom Lane
Martin Brommer <[EMAIL PROTECTED]> writes: > How do I call a function that takes a rowtype for an argument as in: > CREATE FUNCTION myfunc(mytablename) RETURNS INT AS ' SELECT myfunc(mytablename.*) FROM mytablename; This also works at the moment, but seems less clear to me: SELECT myfunc(mytable

Re: [SQL] User-defined SQL function has slower query on 7.3.3 than

2003-08-14 Thread Andrew Droffner
Mr. Lane: QUERY - SELECT ZIPCODE FROM LOCATIONS WHERE COUNTRY = 'USA' AND ZIP_DIST_MI('07306', ZIPCODE) <= 25; I found that the 7.1.3 server performed QUERY very slowly after a VACUUM ANALYZE. (I can't just ANALYZE in this version, right?) It's performance was comparable to the 7.3.3 server f

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread Josh Berkus
G - > Am I reading you right, and statement triggers don't work in 7.3? or some > aspect of the order of statement- and row-level triggers? Correct, they don't work in 7.3. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--

Re: [SQL] sub-sel/group problem

2003-08-14 Thread Christoph Haller
> > select r.rtid, concat(r.rcid::text || ' on ' || l.lnumber::text) as task > from rides r, loco_dets l where r.rlid = l.lid group by rtid; > Looks like another implicit FROM clause mystery. Try ... GROUP BY r.rtid ; The same goes for the JOIN. Regards, Christoph --

Re: [SQL] sub-sel/group problem

2003-08-14 Thread Tomasz Myrta
Hi folks, I don;t know if it's cos it's Monday or what, but I can't see what's wrong here. I've got two tables, turns which holds a turn number, a task, and where appropriate a link to a loco. The select below works but only shows those tasks where a loco is involved.: select r.rtid, con

Re: [SQL] Comparing arrays

2003-08-14 Thread Joe Conway
Bertrand Petit wrote: In two table I store "objects" and their attributes. The attributes, which are not meant to be searched, are stored as unbound arrays of varchars. I have a query that needs to use those attributes on both sides of an EXCEPT statement: SELECT left.id, left.attribs FR

Re: [SQL] (no subject)

2003-08-14 Thread Tom Lane
"A. Van Hook" <[EMAIL PROTECTED]> writes: > Dump files are used to restore and test. This test method has been used > successfully on > all previous versions. However, in 7.3.3, when the dump utility hits a > carriage return imbeded with in a text field, the > dump utility immeadiately jumps to t

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-14 Thread Stephan Szabo
On Mon, 11 Aug 2003, BenLaKnet wrote: > we make a dump before ... and with a product pgmanager (ems tech) we do > not show any foreign keys. That's possible, I'd have guessed that it should be dumping the triggers as CREATE CONSTRAINT TRIGGER commands in the dump. > But I think all of triggers

Re: [SQL] converting interval to timestamp

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thursday 31 July 2003 09:05, teknokrat wrote: > The difference of two dates/timestamps always gives an interval. is > there a way to convert this interval into number such as number of > milliseconds or number of days? > Take a look at the User's

Re: [SQL] possible?

2003-08-14 Thread Franco Bruno Borghesi
If I don't get it worng, you wanna know how many threads you have for each forum, and how many posts you have for each thread... don't you? maybe something like SELECT     F.id AS forumId,     ( SELECT count(id) FROM thread WHERE forumId=F.id ) AS threadCount,     T.id AS threadId,     ( SEL

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On Wed, 13 Aug 2003, ProgHome wrote: > I tried with some LEFT JOINS, which give me the possibility to keep > the information of the right table. > > I have now the following query, which is 10 times faster !!! (from 16s > to 1.6s) > But I'd like to remove the last subquery, to see if it faster ;)

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Franco Bruno Borghesi
Maybe its better now. Anyway, what I think is that joining will perform better than using IN. Am I wrong? SELECT    L.* FROM   lead L   LEFT JOIN purchase P ON (L.id=P.lead_id)   LEFT JOIN member_exclusion M ON (P.member_id=M.member_id_to_exclude)   LEFT JOIN (        SELECT DI

Re: [SQL] RI_ConstraintTrigger_11264756

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thursday 31 July 2003 12:18, Charles Hauser wrote: > All, > > I have inherited a table (below) with a RI trigger. > I believe this table was created where both clone_id & blastx_id are FKs > w/ stipulation 'ON DELETE CASCADE'. > > My question is, is

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On Tue, 12 Aug 2003, Franco Bruno Borghesi wrote: > I *guess* this query does the same as yours (please verify). It does not in general unfortunately. :( I see two possible problems. The first is that by using an inner join you're going to lose any rows where there is no match on the right hand

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread SZŰCS Gábor
Dear Jonathan, thanks for your POV. - Original Message - From: "Jonathan Gardner" <[EMAIL PROTECTED]> Sent: Wednesday, August 13, 2003 6:20 PM > I try to avoid triggers unless it is completely obvious what they are > doing and why I should use them. This tends to minimize the number of

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread Christoph Haller
> > I want to insert descriptions at the columns of my tables but without > > using the command COMMENT ON. I want to do it together with the table > > creation. Is that possible? > > > > I wanna do something like this: > > > > create table test ( > > id serial 'Descripitions about ID', > >

Re: [SQL] optimisation of a code

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Monday 11 August 2003 15:19, krysto wrote: > Hi all > > I wrote a script in PHP with mysql (hum ... to be honnest, I wrote > this script under PostGreSQL but we recently migrated to mysql, so I > had to adapt my code to mysql ... sorry about tha

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-14 Thread Stephan Szabo
On Mon, 11 Aug 2003, [ISO-8859-1] Benoît Bournon wrote: > No trigger > > Just triggers for foreign key in spectacle and none in spectacle_v > > How is it possible to verify triggers for foreign keys ? Generally a select on pg_trigger. Each foreign key should have 3 triggers, 1 on the referencin

Re: [SQL] How to check: is some key referenced from sometable

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Saturday 09 August 2003 14:44, eVl One wrote: > So I need: >"silent delete" - i.e. when trying to DELETE row from A I'll not > fall out with "$1 referential integrity violation - key in A still > referenced from Bxx", but silently doesn't delete

Re: [SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
OK, here is the final query without any subquery ... -- SELECT L. * FROM lead L LEFT JOIN purchase P ON ( L.id = P.lead_id ) LEFT JOIN member_exclusion M ON ( P.member_id = M.member_id_to_exclude ) LEFT JOIN ( SELECT DISTINCT affiliate_locked_id FROM affiliate_lockout W

[SQL] How to speeed up the query performance

2003-08-14 Thread Abdul Wahab Dahalan
How do I speed up the quey performance if I've a query like this : Does 'not in' command will affected the performance?. select      ts.transportid,ts.transporttype,ts.transportcapacity,ts.transportstatus,ts.routecoverage,ts.transportregnumber from       transportsetup ts where     ts.bizid =

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread Rod Taylor
On Wed, 2003-08-13 at 07:56, [EMAIL PROTECTED] wrote: > Hi, > > I want to insert descriptions at the columns of my tables but without > using the command COMMENT ON. I want to do it together with the table > creation. Is that possible? > > I wanna do something like this: > > create table test

Re: [SQL] [GENERAL] Postgresql slow on XEON 2.4ghz/1gb ram

2003-08-14 Thread Martijn van Oosterhout
On Wed, Aug 06, 2003 at 10:50:38AM -0300, Wilson A. Galafassi Jr. wrote: > Hello. > I have this problem: i'm running the postgre 7.3 on a windows 2000 server > with P3 1GHZ DUAL/1gb ram with good performance. For best performance i > have change the server for a XEON 2.4/1gb ram and for my suprise

Re: [SQL] Retrieving tuple data on insert

2003-08-14 Thread sebmil
> you can retrieve it using the currentVal function on the sequence used to > generate that id. Thank you. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-14 Thread BenLaKnet
we make a dump before ... and with a product pgmanager (ems tech) we do not show any foreign keys. But I think all of triggers of referenced table are not deleted. We recreate the schemas ... and now it's running. How is it possible to identify Triggers with no referenced tables ? Stepha

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-14 Thread Benoît Bournon
No trigger Just triggers for foreign key in spectacle and none in spectacle_v How is it possible to verify triggers for foreign keys ? Stephan Szabo a écrit: On Fri, 8 Aug 2003, BenLaKnet wrote: When I duplicate this code in an other table named spectacle_v without Foreygn

Re: [SQL] PostgreSQL and Journaled File Systems

2003-08-14 Thread Tom Lane
Roberto Mello <[EMAIL PROTECTED]> writes: > What is the word about using PG with journaled file systems? I have heard > that it's best to not have the PG journal in a journaled system to avoid > double journaling. Journaling metadata is good. Journaling file contents is redundant --- turn that of

Re: [SQL] Error message with a SQL function

2003-08-14 Thread Tom Lane
[EMAIL PROTECTED] (krysto) writes: > CREATE FUNCTION update_affiliate(int,double precision,double > precision) RETURNS void AS ' UPDATE affiliate SET balance=balance + > $2, balance_in_points=balance_in_points + ( $2 / $3 ) WHERE id = $1; ' > LANGUAGE 'sql'; I don't believe there was a type "v

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread Christoph Haller
> On Wed, Aug 13, 2003 at 02:54:59PM +0200, Christoph Haller wrote: > > \dd test shows > > > > Object descriptions > > Schema | Name | Object | Description > > +--++- > > (0 rows) > > > > This is odd. OK, I know the doc says > > \dd [ pattern ] > > > >

[SQL] Insert a description while creating a table

2003-08-14 Thread luiz
Hi, I want to insert descriptions at the columns of my tables but without using the command COMMENT ON. I want to do it together with the table creation. Is that possible? I wanna do something like this: create table test ( id serial 'Descripitions about ID', name varchar(50) '

[SQL] Testing gateway

2003-08-14 Thread Marc G. Fournier
In theory, the news2mail gateway is back in place ... ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread SZŰCS Gábor
Dear Josh, thanks for the guidelines. - Original Message - From: "Josh Berkus" <[EMAIL PROTECTED]> Sent: Wednesday, August 13, 2003 5:55 PM > My perspective: multiple triggers of the same type on the same table are a > really bad idea if execution order matters. Any setup like this i

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread Christoph Haller
> The docs say in trigger-datachanges.html: > > "Changes made by query Q are visible by queries that are started after query > Q, no matter whether they are started inside Q (during the execution of Q) > or after Q is done. > > This is true for triggers as well ..." > > Trying to understand that, I

Re: [SQL] How to speeed up the query performance

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tuesday 12 August 2003 20:20, Abdul Wahab Dahalan wrote: > How do I speed up the quey performance if I've a query like this : > Does 'not in' command will affected the performance?. > Yes. Severely. See the responses to the "How to optimize this qu

Re: [SQL] Analyze makes queries slow...

2003-08-14 Thread Stef
On Fri, 8 Aug 2003 09:24:48 -0700 Jonathan Gardner <[EMAIL PROTECTED]> wrote: => Try the performance list. Thanks for the tip Stef ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread luiz
Hi Christoph, I'm thinking that the best solution is create a script in perl or python that executes de COMMENT command to me. My initial idea would be comment my columns in a standard way and then run the script. My comment that will turn into description will start with "/*$" instead of the

Re: [SQL] Porting from PL/SQL to PLPGSQL

2003-08-14 Thread Rod Taylor
> we are facing a few problems with PL/SQL Code.. > > 1)In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I > can't find a replacement for that in > PostGreSQL. What does it do? > 2 Oracle have a function USERENV to get the user session > informati

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Vernon Smith
Thanks, Christoph for your thought. An alternative solution I have is to fetch the user table first and act according with the retured value. It doesn't seem to have a single query solution. v. -- - Original Message - DATE: Wed, 13 Aug 2003 13:40:53 From: Christoph Haller <[EM

[SQL] INSERT INTO ... SELECT

2003-08-14 Thread Silke Trissl
Hi, I would like to insert into a table values from a table and user defined ones. Here is the example: I found this statement to insert values from another table: INSERT INTO test_table (cust_id, cust_name) SELECT id, name from CUSTOMER; But the test_table has another column, which should hav

Re: [SQL] How to speeed up the query performance

2003-08-14 Thread Christoph Haller
> > How do I speed up the quey performance if I've a query like this : > Does 'not in' command will affected the performance?. Yes, it's well known to be slow in 7.3 and lower, should be fixed in 7.4 AFAIK. > > select > ts.transportid,ts.transporttype,ts.transportcapacity,ts.transportstatus,ts.rout

Re: [SQL] How to speeed up the query performance

2003-08-14 Thread Abdul Wahab Dahalan
Hai Chris! Thanks for the solution but seem it doesnt work. (0 rows) returned when I used NOT EXITS but (4 rows) returned when NOT IN is used... FYI I used 7.2 Christoph Haller wrote: How do I speed up the quey performance if I've a query like this : Does 'not in' comm

[SQL] Error message with a SQL function

2003-08-14 Thread krystoffff
Hi I try to create the following SQL function: CREATE FUNCTION update_affiliate(int,double precision,double precision) RETURNS void AS ' UPDATE affiliate SET balance=balance + $2, balance_in_points=balance_in_points + ( $2 / $3 ) WHERE id = $1; ' LANGUAGE 'sql'; but when I submit this query dire

Re: [SQL] How to optimize this query ?

2003-08-14 Thread ProgHome
Sorry, I posted the following message on the newsgroups, but it seems that you didn't see it ... I tried with some LEFT JOINS, which give me the possibility to keep the information of the right table. I have now the following query, which is 10 times faster !!! (from 16s to 1.6s) But I'd like t

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On 13 Aug 2003, Franco Bruno Borghesi wrote: > Maybe its better now. Anyway, what I think is that joining will perform > better than using IN. Am I wrong? Generally that's true (for 7.3 and earlier). For 7.4 IN has gotten much better, and you probably want to retry with IN. However, it's possib

[SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
Hi all I have to optmize this query, because it takes a while to run (about 30s) Here are the tables (with the keys): affiliate_lockout (6 rows) (member_id, affiliate_id) lead (4490 rows) (id, ...) member (6 rows) (id, ...) member_exclusion (3 rows)(member_id, m

[SQL] Query suddenly taking longer....

2003-08-14 Thread Kurt Overberg
Hi all, I have the following query on postgresql 7.3.2 on RedHat 7. select *, (select count(*) from xrefmembergroup where membergroupid = m.id) as numberingroup from membergroup m; (basically- try to get a list of 'groups' and the number of members in each group) The xrefmembergroup table has abo

[SQL] Changing data type must recreate all views?

2003-08-14 Thread Yudie
I need to change column data type from integer to float8 That mean to droping table and recreate a new one and can lost the original object id. Do i need to recreate all views and triggers that relate to that table? if that so, is there anyway to do that without touching views and triggers? Thank

Re: [SQL] How to speeed up the query performance

2003-08-14 Thread Stephan Szabo
On Thu, 14 Aug 2003, Abdul Wahab Dahalan wrote: > Hai Chris! > Thanks for the solution but seem it doesnt work. > (0 rows) returned when I used NOT EXITS but (4 rows) returned > when NOT IN is used... Maybe you need a set of parenthesis around the old conditions because of the or.

Re: [SQL] Timezone troubles

2003-08-14 Thread Tom Lane
Jesse Scott <[EMAIL PROTECTED]> writes: >> Ok, I was actually dyslexic when I read the version number, I have >> 7.3.2 not 7.2.3, I'll investigate the timezone status though. In that case I think you are looking for this 7.3.3 fix: 2003-02-27 16:37 tgl * src/backend/utils/adt/timestamp

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Christoph Haller
> > Coincidentally, I have a very similar case using some twists. > > The table I want to insert data is something like > > table A ( > user01 int, > user02 int, > ... > primary key (user01, user02), > CHECK ( user01 < user02 ) > ); > > And the user table is: > > tabe user_table ( > user int constr

Re: [SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
I tried with some LEFT JOINS, which give me the possibility to keep the information of the right table. I have now the following query, which is 10 times faster !!! (from 16s to 1.6s) But I's like to remove the last subquery, to see if it faster ;) Can somebody help me ?

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On 12 Aug 2003, krysto wrote: > Hi all > > I have to optmize this query, because it takes a while to run (about > 30s) > > Here are the tables (with the keys): > affiliate_lockout (6 rows) (member_id, affiliate_id) > lead (4490 rows) (id, ...) > member (6 rows) (i

[SQL] Porting from PL/SQL to PLPGSQL

2003-08-14 Thread Jomon Skariah
Hi, We are in the process of migrating of our application from Oracle to PostGreSQL. we are facing a few problems with PL/SQL Code.. 1) In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I can't find a replacement for that in PostGreSQL. 2 Oracl

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread Josh Berkus
G: > * what is sure about trigger execution order? >(Cristoph Haller partially answered my question, quoting future plans) My perspective: multiple triggers of the same type on the same table are a really bad idea if execution order matters. Any setup like this is automatically maintenen

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread Benoît Bournon
comment on table "test" is 'fziofeiozfiezojfezjfeziojfeziojf ezfjioezifj ezio' ; Rod Taylor wrote: On Wed, 2003-08-13 at 07:56, [EMAIL PROTECTED] wrote: Hi, I want to insert descriptions at the columns of my tables but without using the command COMMENT ON. I want to do it to

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread Reinoud van Leeuwen
On Wed, Aug 13, 2003 at 02:54:59PM +0200, Christoph Haller wrote: > \dd test shows > > Object descriptions > Schema | Name | Object | Description > +--++- > (0 rows) > > This is odd. OK, I know the doc says > \dd [ pattern ] > > Shows the description

Re: [SQL] How to optimize this query ?

2003-08-14 Thread ProgHome
Title: RE: [SQL] How to optimize this query ? Actually, I have got another query where I need to remove the subqueries ... It is almost the same query but this time, I don't search in the table LEAD but in the table MEMBER … HERE are the tables:  affiliate_lockout  (6 rows)  (member_id, aff

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wednesday 13 August 2003 08:40, SZŰCS Gábor wrote: > Actually, the situation I painted is much much simplified compared to > the real one (about 20 or more tables are accessed during that > "simple 1-line update"). What I'd probably use best, are so

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread BenLaKnet
create table test ( id serial , name varchar(50)  );    COMMENT ON TABLE "test" IS 'MySQL table id_training_form ... id_form_unique'; comment on COLUMN "test"."id" is 'greigjreoigjreigjore iojrjiogre' ; Doc postgresql comment Rod Taylor wrote: On Wed, 2003-08-13 at 07:56, [E

Re: [SQL] Error message with a SQL function

2003-08-14 Thread krystoffff
Thanks You were right, it was because of the return void But I think in the documentation, I read somewhere that this kind of return was allowed ... I must have mistaken ... ---(end of broadcast)--- TIP 6: Have you searched our list archives?

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On Wed, 13 Aug 2003, ProgHome wrote: > select member.id, automated.delivery, member.email > > from (automated INNER JOIN member ON member.id = automated.member_id) > > where activated=1 > and website='$SITE_NAME' > and (select count(*) from trans_member where > (unix_timestamp(now())-unix_tim

Re: [SQL] Order of triggers - totally lost

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wednesday 13 August 2003 03:11, SZŰCS Gábor wrote: > > What may be wrong? Any ideas to re-organize parts of the triggers? > May putting the update to an A_AU trigger help? I tried it, still > have problems (not sure it's still the trigger order), bu

[SQL] lower/upper functions and strings in searches

2003-08-14 Thread Gregory S. Williamson
I am obviuously doing some newbie trick, and I ordinarily would spend time browing the archives, but the archives.postgresql.org site seems to be absurdly slow. This is 7.3.3 on a linux box. I have a bunch of data with state, city, county and country names. When our application does a search fo

[SQL] Order of triggers - totally lost

2003-08-14 Thread SZŰCS Gábor
Dear Gurus, Please help to solve this chaos: I have a simple query that triggers several plpgsql triggers on several tables. Table A has a BIUD (Before Insert or Update or Delete) trigger (henceforth A_BIUD and analogues). Table B has triggers BIUD, AI and AU. Table B1 has triggers BIUD and AD.

Re: [SQL] lower/upper functions and strings in searches

2003-08-14 Thread Stephan Szabo
On Thu, 14 Aug 2003, Gregory S. Williamson wrote: > I am obviuously doing some newbie trick, and I ordinarily would spend time browing > the archives, but the archives.postgresql.org site seems to be absurdly slow. > > This is 7.3.3 on a linux box. > > I have a bunch of data with state, city, cou

Re: [SQL] Query suddenly taking longer....

2003-08-14 Thread Kurt Overberg
Tom, Thanks for the reply. I agree that the query seemed inefficient, but it ran so quickly I thought it was okay. The only difference between the two servers was that the fast one used an Index Scan while the other (the now-slow one) would use a sequential scan. The query as you re-wrote i

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Vernon Smith
Coincidentally, I have a very similar case using some twists. The table I want to insert data is something like table A ( user01 int, user02 int, ... primary key (user01, user02), CHECK ( user01 < user02 ) ); And the user table is: tabe user_table ( user int constraint pk_user primary key UNIQ

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Christopher Browne
Centuries ago, Nostradamus foresaw when [EMAIL PROTECTED] (Silke Trissl) would write: > I would like to insert into a table values from a table and user > defined ones. Here is the example: > > I found this statement to insert values from another table: > > INSERT INTO test_table (cust_id, cust_nam

Re: [SQL] lower/upper functions and strings in searches

2003-08-14 Thread Josh Berkus
Gregory, > I just know I'm overlooking some real obvious thing but for some reason this eludes me. I could see if the search was very slow (the function returns type "text" and the indexed columns are of type CHAR(). Char(what?) ? if it's, say CHAR(4) that could be your problem; 'NM'::undefin

Re: [SQL] sub-sel/group problem

2003-08-14 Thread Stephan Szabo
On Mon, 11 Aug 2003, Gary Stainburn wrote: > I don;t know if it's cos it's Monday or what, but I can't see what's wrong > here. > > I've got two tables, turns which holds a turn number, a task, and where > appropriate a link to a loco. The select below works but only shows those > tasks where a l

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Franco Bruno Borghesi
I *guess* this query does the same as yours (please verify). SELECT L.* FROM lead L INNER JOIN purchase P ON (L.id=P.lead_id) INNER JOIN affiliate_lockout A ON (L.affiliate_id=A.affiliate_locked_id) INNER JOIN member_exclusion M ON (P.member_id=M.member_id_t

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Monday 11 August 2003 03:21, Silke Trissl wrote: > > Is there something like > > INSERT INTO test_table (int_id, cust_id, cust_name) '1', SELECT id, > name from CUSTOMER: > > and if so, what ist the correct statement? If not, what is an > alternativ

[SQL] sub-sel/group problem

2003-08-14 Thread Gary Stainburn
Hi folks, I don;t know if it's cos it's Monday or what, but I can't see what's wrong here. I've got two tables, turns which holds a turn number, a task, and where appropriate a link to a loco. The select below works but only shows those tasks where a loco is involved.: select r.rtid, concat(

Re: [SQL] Query suddenly taking longer....

2003-08-14 Thread Tom Lane
Kurt Overberg <[EMAIL PROTECTED]> writes: > I have the following query on postgresql 7.3.2 on RedHat 7. > select *, (select count(*) from xrefmembergroup where membergroupid = > m.id) as numberingroup from membergroup m; > The xrefmembergroup table has about 120,000 rows, membergroup has 90. > T

[SQL] OFF-TOPIC: Richard Huxton, Please Contact Us!

2003-08-14 Thread Josh Berkus
Richard: Ned Lily and I have been sending you e-mails for 3 weeks, and you have not responded. Since you've posted to the SQL list in that time, I can only think that you're not getting our e-mails. I'm hoping that by sending you via the SQL list, you'll receive the e-mail. Please contact u

Re: [SQL] Comparing arrays

2003-08-14 Thread Tom Lane
Bertrand Petit <[EMAIL PROTECTED]> writes: > That query can't be planed because of the following error: "Unable to > identify an ordering operator '<' for type 'character varying[]'". This shortcoming is (at long last) repaired for 7.4. There is no simple solution in earlier releases, I fear. >

[SQL] Porting from PL/SQL to PLPGSQL

2003-08-14 Thread Jomon Skariah
> Hi, > > We are in the process of migrating of our application from Oracle to > PostGreSQL. > > > we are facing a few problems with PL/SQL Code.. > > 1)Can we perform DML statements on VIEWS in PostGreSQL as we do in > ORACLE? > Do I need to create some RULES for that ?? > >

[SQL] Abort Transaction DP PK (again)

2003-08-14 Thread alexandre :: aldeia digital
Hi, I know that this topic was discuted before but I like an alternative for my high load INSERT query. Why Postgres abort a transaction when find a duplicate PK ?!?! A simple Fuction test: (...) SELECT a,b from foo where a=1 and b=1 IF NOT FOUND INSERT INTO foo VALUES(1,1) ELSE UP

Re: [SQL] How to optimize this query ?

2003-08-14 Thread krystoffff
For the following query, I have a little problem ... First, I have to rewrite several times the same query because the alias are not recognised in the same query ( I got an error when I try to reuse the alias "nb_bogus_leads", for instance). Do you have a way to avoid this ? Because If I do so, the

Re: [SQL] Abort Transaction DP PK (again)

2003-08-14 Thread Josh Berkus
Alexandre, > I know that this topic was discuted before but I like an alternative for > my high load INSERT query. > Why Postgres abort a transaction when find a duplicate PK ?!?! Postgres currently aborts a transaction upon *any* error condition, except warnings. We do not, currently, have a e

[SQL] Optional join

2003-08-14 Thread Slawek Jarosz
Hi, I trying to write a query that will join 2 tables. Here's the concept: Table 1: table1, primary key pk1 Table 2: table2, primary key pk2 One of the fields (f2) in table2 contains either the primary key of table1 or a NULL value. So normally a pretty basic query: SELECT table1.*, table2

Re: [SQL] Porting from PL/SQL to PLPGSQL

2003-08-14 Thread Jomon Skariah
Hi Josh, Thanks for your reply. In our PL/SQL code we have used userenv('LANG') in some of the INSERT statements. Do we have a replacement for this.. Regards Jomon -Original Message- From: Josh Berkus [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 1:05 AM To: Jomon Ska

[SQL] JDBC encoding problem

2003-08-14 Thread Kurt Overberg
I'm having a rather strange problem that I'm hoping someone can help me with. I'm using Struts 1.0/jsp on Debian linux under Tomcat 4.1.x and the blackdown JVM . I'm attempting to convert my current SQL_ASCII database to UNICODE. I'm new to this, so am most likely making a few mistakes. He

Re: [SQL] User-defined SQL function has slower query on 7.3.3 than 7.1.3

2003-08-14 Thread Tom Lane
Andrew Droffner <[EMAIL PROTECTED]> writes: > I have this QUERY (below) that PostgreSQL 7.3.X servers run MUCH slower > than > the 7.1.3 server does. I know of no reason for that to happen. Have you vacuum analyzed the 7.3 database? > It finds the ZIPs locations with a prepared > (and saved) SPI

Re: [SQL] Timestamp in PG - 7.1 & 7.2

2003-08-14 Thread Tom Lane
"Anagha Joshi" <[EMAIL PROTECTED]> writes: > Here is output from PostgreSQL 7.2.4: > =20 > trapdb=3D# select cast(datetime(1057637700) as timestamp); > timestamp > --- > 2003-07-07 22:45:00+05:30 > (1 row) > =20 > I've migrated from PG - 7.1.2 to 7.2.4. Not sure w

[SQL] Postgresql slow on XEON 2.4ghz/1gb ram

2003-08-14 Thread Wilson A. Galafassi Jr.
Hello. I have this problem: i'm running the postgre 7.3 on a windows 2000 server with  P3 1GHZ DUAL/1gb ram with good performance. For best performance i have change the server for a  XEON 2.4/1gb ram and for  my suprise the performance decrease 80%. anybody have a similar experience? does

[SQL] User-defined SQL function has slower query on 7.3.3 than 7.1.3

2003-08-14 Thread Andrew Droffner
I have this QUERY (below) that PostgreSQL 7.3.X servers run MUCH slower than the 7.1.3 server does. It makes sense that both servers have to do a sequential scan over the ZIPCODE column. There are over 7,500 rows in the LOCATIONS table. Does anyone know what changed in the planner or optimizer? Can

Re: [SQL] Optional join

2003-08-14 Thread Bruno Wolff III
On Thu, Aug 14, 2003 at 10:40:02 -0400, Slawek Jarosz <[EMAIL PROTECTED]> wrote: > Hi, > > I trying to write a query that will join 2 tables. Here's the concept: > Table 1: table1, primary key pk1 > Table 2: table2, primary key pk2 > > One of the fields (f2) in table2 contains either the pr

Re: [SQL] Optional join

2003-08-14 Thread Stephan Szabo
On Thu, 14 Aug 2003, Slawek Jarosz wrote: > Hi, > > I trying to write a query that will join 2 tables. Here's the concept: > Table 1: table1, primary key pk1 Table 2: table2, primary key pk2 > > One of the fields (f2) in table2 contains either the primary key of > table1 or a NULL value. So

[SQL] Why table has drop, but the foreign key still there?

2003-08-14 Thread Raymond Chui
Here are the simple things I did create table state ( state_code char(2) not null, state varchar(15) not null, primary key (state_code) ); create table whitepage ( user_id char(8) not null, email varchar(50), telephone char(16) not null, contact_namevarchar(30) not null,

Re: [SQL] [ADMIN] Why table has drop, but the foreign key still there?

2003-08-14 Thread Stephan Szabo
On Wed, 13 Aug 2003, Raymond Chui wrote: > > Here are the simple things I did > > create table state ( > state_code char(2) not null, > state varchar(15) not null, > primary key (state_code) > ); > > create table whitepage ( > user_id char(8) not null, > email varchar(50), > tele

[SQL] update system table?

2003-08-14 Thread Eric Anderson Vianet SAO
how could I fix this problem:   ERROR:  unexpected chunk number 8 (expected 0) for toast value 6935693   It appear to be simple: update chunk_seq from 8 to 0. how to do it?   in the stand alone postgres, could I copy a entire table? how to do it?   tnx   Eric  

  1   2   >