[PERFORM] Nested loop performance

2003-12-16 Thread Nick Fankhauser
Hi- I'm trying to optimize a query that I *think* should run very fast. Essentially, I'm joining two tables that have very selective indexes and constraining the query on an indexed field. (There's a third small lookup table in the mix, but it doesn't really affect the bottom line.) actor is a

[PERFORM] Optimizing FK PK performance...

2003-12-16 Thread Sean P. Thomas
I am working on migrating to postgres and had some questions regarding optimization that I could not find references in the documentation: 1. Is there any performance difference for declaring a primary or foreign key a column or table contraint? From the documentation, which way is faster

[PERFORM] Why is VACUUM ANALYZE table so slow?

2003-12-16 Thread David Shadovitz
I'm running PG 7.2.2 on RH Linux 8.0. I'd like to know why VACUUM ANALYZE table is extemely slow (hours) for certain tables. Here's what the log file shows when I run this command on my employees table, which has just 5 columns and 55 records: VACUUM ANALYZE employees DEBUG: --Relation

Re: [PERFORM] Measuring execution time for sql called from PL/pgSQL

2003-12-16 Thread David Shadovitz
I've tried to measure the duration of sql with printing out localtimestamp but for some reason during the same pg/plsql call it returns the same value: Aram, From http://www.postgresql.org/docs/current/static/functions-datetime.html: There is also the function timeofday(), which for

Re: [PERFORM] Excessive rows/tuples seriously degrading query

2003-12-16 Thread Hannu Krosing
Chadwick, Russell kirjutas L, 13.12.2003 kell 00:40: Hello everyone. Can anyone explain why this table which has never had more than a couple rows in it shows 500k in the query planner even after running vacuum full. Its terribly slow to return 2 rows of data. The 2 rows in it are being

Re: [PERFORM] Optimizing FK PK performance...

2003-12-16 Thread Neil Conway
Sean P. Thomas [EMAIL PROTECTED] writes: 1. Is there any performance difference for declaring a primary or foreign key a column or table contraint? From the documentation, which way is faster and/or scales better: CREATE TABLE distributors ( did integer, name

Re: [PERFORM] Why is VACUUM ANALYZE table so slow?

2003-12-16 Thread Neil Conway
David Shadovitz [EMAIL PROTECTED] writes: I'm running PG 7.2.2 on RH Linux 8.0. Note that this version of PostgreSQL is quite old. I'd like to know why VACUUM ANALYZE table is extemely slow (hours) for certain tables. Is there another concurrent transaction that has modified the table but

[PERFORM] update slows down in pl/pgsql function

2003-12-16 Thread Jenny Zhang
I have stored procedure written in pl/pgsql which takes about 13 seconds to finish. I was able to identify that the slowness is caused by one update SQL: UPDATE shopping_cart SET sc_sub_total=sc_subtotal, sc_date=now() WHERE sc_id=sc_id; If I comment this sql out, the stored procedure

Re: [PERFORM] [GENERAL] update slows down in pl/pgsql function

2003-12-16 Thread Stephan Szabo
On Tue, 16 Dec 2003, Jenny Zhang wrote: I have stored procedure written in pl/pgsql which takes about 13 seconds to finish. I was able to identify that the slowness is caused by one update SQL: UPDATE shopping_cart SET sc_sub_total=sc_subtotal, sc_date=now() WHERE sc_id=sc_id; Umm, is

Re: [PERFORM] [GENERAL] update slows down in pl/pgsql function

2003-12-16 Thread Jenny Zhang
Oops, I named the var name the same as the column name. Changing it to something else solved the problem. Thanks, Jenny On Tue, 2003-12-16 at 15:54, Stephan Szabo wrote: On Tue, 16 Dec 2003, Jenny Zhang wrote: I have stored procedure written in pl/pgsql which takes about 13 seconds to

Re: [PERFORM] Optimizing FK PK performance...

2003-12-16 Thread Christopher Kings-Lynne
1. Is there any performance difference for declaring a primary or foreign key a column or table contraint? From the documentation, which way is faster and/or scales better: CREATE TABLE distributors ( did integer, namevarchar(40), PRIMARY KEY(did) ); CREATE TABLE

Re: [PERFORM] Nested loop performance

2003-12-16 Thread Stephan Szabo
On Tue, 16 Dec 2003, Nick Fankhauser wrote: Is there a more efficient means than a nested loop to handle such a join? Would a different method be chosen if there was exactly one row in actor_summary for every row in actor? As a question, what does explain analyze give you if you set

Re: [PERFORM] [HACKERS] fsync method checking

2003-12-16 Thread Manfred Spraul
Bruce Momjian wrote: write 0.000360 write fsync 0.001391 write, close fsync 0.001308 open o_fsync, write0.000924 That's 1 milliseconds vs. 1.3 milliseconds. Neither value is realistic - I guess the hw cache on and the os doesn't issue cache flush

Re: [PERFORM] [HACKERS] fsync method checking

2003-12-16 Thread Zeugswetter Andreas SB SD
Running the attached test program shows on BSD/OS 4.3: write 0.000360 write fsync 0.001391 I think the write fsync pays for the previous write test (same filename). write, close fsync 0.001308 open o_fsync, write0.000924 I have

Re: [PERFORM] Why is VACUUM ANALYZE table so slow?

2003-12-16 Thread David Shadovitz
Neil, Thanks for the good advice. I noticed that I had some sessions for which I could not account, and I think even a 2nd postmaster running. It looks like I've cleaned everything up, and now I can VACUUM and I can DROP an index which wouldn't drop. And I'm looking into upgrading

[PERFORM] Why is restored database faster?

2003-12-16 Thread David Shadovitz
I backed up my database using pg_dump, and then restored it onto a different server using psql. I see that the query SELECT COUNT(*) FROM myTable executes immediately on the new server but takes several seconds on the old one. (The servers are identical.) What could account for this

Re: [PERFORM] Why is restored database faster?

2003-12-16 Thread Shridhar Daithankar
Neil Conway wrote: How can I get the original server to perform as well as the new one? Well, you have the answer. Dump the database, stop postmaster and restore it. That should be faster than original one. (BTW, SELECT count(*) FROM table isn't a particularly good DBMS performance

Re: [PERFORM] Why is restored database faster?

2003-12-16 Thread Dennis Bjorklund
On Tue, 16 Dec 2003, David Shadovitz wrote: I backed up my database using pg_dump, and then restored it onto a different server using psql. I see that the query SELECT COUNT(*) FROM myTable executes immediately on the new server but takes several seconds on the old one. (The servers are