Re: [PERFORM] faster search

2005-06-11 Thread Cosimo Streppone
Steve Atkins wrote: On Fri, Jun 10, 2005 at 01:45:05PM -0400, Clark Slater wrote: Hi- Would someone please enlighten me as to why I'm not seeing a faster execution time on the simple scenario below? [...] Create an index on (productlistid, typeid, partnumber) then select * from test

Re: [PERFORM] faster search

2005-06-11 Thread Tom Lane
John A Meinel [EMAIL PROTECTED] writes: I am a little surprised that it is taking 40s to scan only 400k rows, though. Yeah, that seemed high to me too. Table bloat maybe? It would be interesting to look at the output of vacuum verbose test to see how much dead space there is.

Re: [PERFORM] faster search

2005-06-10 Thread Steinar H. Gunderson
On Fri, Jun 10, 2005 at 01:45:05PM -0400, Clark Slater wrote: Indexes: test_id btree (id) test_plid btree (productlistid) test_typeid btree (typeid) test_plidtypeid btree (productlistid, typeid) explain analyze select * from test where productlistid=3 and typeid=9 order by partnumber

[PERFORM] faster search

2005-06-10 Thread Clark Slater
Hi- Would someone please enlighten me as to why I'm not seeing a faster execution time on the simple scenario below? there are 412,485 rows in the table and the query matches on 132,528 rows, taking almost a minute to execute. vaccuum analyze was just run. Thanks! Clark test

Re: [PERFORM] faster search

2005-06-10 Thread Tobias Brox
[Clark Slater - Fri at 01:45:05PM -0400] Would someone please enlighten me as to why I'm not seeing a faster execution time on the simple scenario below? Just some thoughts from a novice PG-DBA .. :-) My general experience is that PG usually prefers sequal scans to indices if a large portion

Re: [PERFORM] faster search

2005-06-10 Thread John A Meinel
Clark Slater wrote: Hi- Would someone please enlighten me as to why I'm not seeing a faster execution time on the simple scenario below? there are 412,485 rows in the table and the query matches on 132,528 rows, taking almost a minute to execute. vaccuum analyze was just run. Well,

Re: [PERFORM] faster search

2005-06-10 Thread Steve Atkins
On Fri, Jun 10, 2005 at 01:45:05PM -0400, Clark Slater wrote: Hi- Would someone please enlighten me as to why I'm not seeing a faster execution time on the simple scenario below? Because you need to extract a huge number of rows via a seqscan, sort them and then throw them away, I think.

Re: [PERFORM] faster search

2005-06-10 Thread Clark Slater
hmm, i'm baffled. i simplified the query and it is still taking forever... test - id| integer partnumber| character varying(32) productlistid | integer typeid| integer Indexes: test_productlistid btree (productlistid) test_typeid

Re: [PERFORM] faster search

2005-06-10 Thread Joshua D. Drake
Clark Slater wrote: hmm, i'm baffled. i simplified the query and it is still taking forever... What happens if you: alter table test alter column productlistid set statistics 150; alter table test alter column typeid set statistics 150; explain analyze select * from test where

Re: [PERFORM] faster search

2005-06-10 Thread Clark Slater
thanks for your suggestion. a small improvement. still pretty slow... vbp=# alter table test alter column productlistid set statistics 150; ALTER TABLE vbp=# alter table test alter column typeid set statistics 150; ALTER TABLE vbp=# explain analyze select * from test where (productlistid=3 and

Re: [PERFORM] faster search

2005-06-10 Thread Joshua D. Drake
Clark Slater wrote: thanks for your suggestion. a small improvement. still pretty slow... vbp=# alter table test alter column productlistid set statistics 150; ALTER TABLE vbp=# alter table test alter column typeid set statistics 150; ALTER TABLE vbp=# explain analyze select * from test where

Re: [PERFORM] faster search

2005-06-10 Thread Joshua D. Drake
Clark Slater wrote: thanks for your suggestion. a small improvement. still pretty slow... vbp=# alter table test alter column productlistid set statistics 150; ALTER TABLE vbp=# alter table test alter column typeid set statistics 150; ALTER TABLE vbp=# explain analyze select * from test where

Re: [PERFORM] faster search

2005-06-10 Thread Clark Slater
Query should return 132,528 rows. vbp=# set enable_seqscan = false; SET vbp=# explain analyze select * from test where (productlistid=3 and typeid=9); QUERY PLAN Index Scan using test_typeid on

Re: [PERFORM] faster search

2005-06-10 Thread Joshua D. Drake
Clark Slater wrote: Query should return 132,528 rows. O.k. then the planner is doing fine it looks like. The problem is you are pulling 132,528 rows. I would suggest moving to a cursor which will allow you to fetch in smaller chunks much quicker. Sincerely, Joshua D. Drake vbp=# set