Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > Actually, just thought of something else. If you remove > the probably redundant p.song_id=s.song_id from the second > query (since the join ... using should do that) does it > change the explain output? I was just about to point that out. The WHERE

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread Stephan Szabo
Actually, just thought of something else. If you remove the probably redundant p.song_id=s.song_id from the second query (since the join ... using should do that) does it change the explain output? On Fri, 9 Mar 2001, David Olbersen wrote: > On Fri, 9 Mar 2001, Stephan Szabo wrote: > > ->As

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread Stephan Szabo
Darn. Well, one of the queries picked that 1 row was going to survive the nested loop step and the other said 14. I was wondering which one was closer to being correct at that time. On Fri, 9 Mar 2001, David Olbersen wrote: > On Fri, 9 Mar 2001, Stephan Szabo wrote: > > ->As a question, how

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread David Olbersen
On Fri, 9 Mar 2001, Stephan Szabo wrote: ->As a question, how many rows does ->select * from playlist p join songs s using (song_id) where ->p.waiting=TRUE; ->actually result in? Well it depends. Most of the time that playlist table is "empty" (no rows where waiting = TRUE), however users can (i

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread Stephan Szabo
On Fri, 9 Mar 2001, David Olbersen wrote: > On Fri, 9 Mar 2001, Stephan Szabo wrote: > > -> Hmm, what were the two queries anyway? > > The "slower" query > > SELECT > to_char( p.insertion_time, 'HH:MI AM MM/DD' ) as time_in, > s.nameas title, >

Re: [SQL] from PosgreSQL 7.1b3 to 7.0.3

2001-03-09 Thread Christopher Sawtell
On Sun, 11 Mar 2001 05:27, Najm Hashmi wrote: > I have PosgreSQL 7.1b3 running on one of our test servers. It seems > like PosgreSQL 7.1b3 is not very stable. I want to go back to 7.0.3v > since it it the most stable version available. Another, imho better, alternative is to move forward to e

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread David Olbersen
On Fri, 9 Mar 2001, Stephan Szabo wrote: -> Hmm, what were the two queries anyway? The "slower" query SELECT to_char( p.insertion_time, 'HH:MI AM MM/DD' ) as time_in, s.nameas title, a.nameas artist, s.length as le

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread Stephan Szabo
> On Fri, 9 Mar 2001, Stephan Szabo wrote: > > ->Not entirely. Those are only estimates, so they don't entirely line up > ->with reality. Also, I notice the first estimates 14 rows and the second > ->1, which is probably why the estimate is higher. In practice it probably > ->won't be signif

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread David Olbersen
On Fri, 9 Mar 2001, Stephan Szabo wrote: ->Not entirely. Those are only estimates, so they don't entirely line up ->with reality. Also, I notice the first estimates 14 rows and the second ->1, which is probably why the estimate is higher. In practice it probably ->won't be significantly diffe

Re: [SQL] Optimization via explicit JOINs

2001-03-09 Thread Stephan Szabo
On Fri, 9 Mar 2001, David Olbersen wrote: > Greetings, > I've been toying aroudn with postgres 7.1beta5's ability to control the > planner via explicitely JOINing tables. I then (just for giggles) compare the > difference in the EXPLAIN results. > > I'm no super-mondo-DBA or anything, b

[SQL] Optimization via explicit JOINs

2001-03-09 Thread David Olbersen
Greetings, I've been toying aroudn with postgres 7.1beta5's ability to control the planner via explicitely JOINing tables. I then (just for giggles) compare the difference in the EXPLAIN results. I'm no super-mondo-DBA or anything, but in my two attempts so far, the numbers I get out of

RE: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Stephan Szabo
On Fri, 9 Mar 2001, Creager, Robert S wrote: > > Well, that explains why I wasn't seeing any appreciable speed increase with > the INITIALLY DEFERRED. I tried mucking in pg_class, and saw a 3 fold > increase in insert speed on inserts into my table with 2 relational > triggers. SET CONSTRAINTS

RE: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Creager, Robert S
Well, that explains why I wasn't seeing any appreciable speed increase with the INITIALLY DEFERRED. I tried mucking in pg_class, and saw a 3 fold increase in insert speed on inserts into my table with 2 relational triggers. SET CONSTRAINTS ALL DEFERRED does nothing to very little to increase th

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Stephan Szabo
On Fri, 9 Mar 2001, Josh Berkus wrote: > Robert, > > > I suspect that the INSERT INTO SELECT in this case will take longer than a > > CREATE TABLE AS because of the referential integrity check needed on every > > INSERT (per Tom Lane). > > In that case, what about: > > a) dropping the referent

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Josh Berkus
Robert, > I suspect that the INSERT INTO SELECT in this case will take longer than a > CREATE TABLE AS because of the referential integrity check needed on every > INSERT (per Tom Lane). In that case, what about: a) dropping the referential integrity check; 2) making the referential integrity c

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Peter Eisentraut
Creager, Robert S writes: > psql -d tassiv -c "\ > create table observationsII ( \ > ra float8 not null, \ > decl float8 not null, \ > mag float8 not null, \ > smag float8 not null, \ > obs_id serial, \ > file_id int4 references files on delete cascade, \ > star_id int4 references comp_loc on del

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Josh Berkus
Robert, > How then can I add in a DEFAULT nextval in place of SERIAL and get > the > REFERENCES in there? Or can I? You can't (as far as I know). If that's important to you, you need to create the table first with a regular CREATE TABLE statement, then do INSERT INTO. CREATE TABLE AS is, I b

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Tom Lane
"Creager, Robert S" <[EMAIL PROTECTED]> writes: > And the next question, should this really be taking 3 hours to insert 315446 > records? I noticed the disk is basically idle during the few times when I > watched. Would this be because of the index created on obs_id? Not for a single index. I

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Josh Berkus
Robert, > Thanks for the pointers. I'm actually working on modifying the structure of > an existing db, so this is all within Pg. Those INSERT INTOs with SELECTs > are painfully slow, and I have an larger table to do this to... I guess > Perl will have to rescue me... Why don't you post your

Re: [SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Josh Berkus
Robert, I can't help you with your performance problem, but I can help you with CREATE TABLE AS. You've mistaken the syntax; CREATE TABLE AS does not use column definitions other than the query. Thus, the correct syntax should be: > create table observationsII > AS select o.ra, o.decl

Re: [SQL] List Concatination

2001-03-09 Thread Josh Berkus
Tom, Richard, Thanks for the advice, guys! This being Postgres, I *knew* there would be other options. > > create aggregate catenate(sfunc1=textcat, basetype=text, > stype1=text, initcond1=''); > > > Then group by client and catenate(firstname || ' ' || lastname) > > With a custom agg

Re: [SQL] from PosgreSQL 7.1b3 to 7.0.3

2001-03-09 Thread Tom Lane
Najm Hashmi <[EMAIL PROTECTED]> writes: > By the way 7.1b3 is crashing 3 to 4 times a week. It would be nice to have some bug reports that might allow us to fix those crashes. And no, you can't go back to 7.0 without dump/initdb/reload. regards, tom lane

Re: [SQL] List Concatination

2001-03-09 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > But - if you don't care about the order of contacts you can define an > aggregate function: > create aggregate catenate(sfunc1=textcat, basetype=text, stype1=text, initcond1=''); > Then group by client and catenate(firstname || ' ' || lastname) With

[SQL] cannot get CREATE TABLE AS to work

2001-03-09 Thread Creager, Robert S
I'm sure I'm doing something wrong, and I'm hoping someone can show me the way of things. Running 7.1beta5 on an Ultra 5, Solaris 2.6 w/256Mb mem. If I remove the AS, the table creates correctly and I can do the INSERT INTO with the SELECT clause psql -d tassiv -c "\ create table observationsI

[SQL] from PosgreSQL 7.1b3 to 7.0.3

2001-03-09 Thread Najm Hashmi
I have PosgreSQL 7.1b3 running on one of our test servers. It seems like PosgreSQL 7.1b3 is not very stable. I want to go back to 7.0.3v since it it the most stable version available. I am just wondering what should I do. can I reinstall 7.0.3 on 7.1b3 directly ? If not then what steps should

Re: [SQL] perl dbd

2001-03-09 Thread Johan Van den Brande
Hi, probably some environment variables are not set... these are used by the DBD::Pg install to determine include and lib directories: POSTGRES_INCLUDE POSTGRES_LIB if you installed postgres into /opt/postgres do export POSTGRES_INCLUDE=/opt/postgres/include export POSTGRES_LIB=/opt/postgres/lib

Re: [SQL] List Concatination

2001-03-09 Thread Richard Huxton
Josh Berkus wrote: > I have an interesting problem. For purpose of presentation to users, > I'd like to concatinate a list of VARCHAR values from a subtable. To > simplify my actual situation: > > What I'd like to be able to do is present a list of clients and their > comma-seperated co