| From: | Josh Berkus <josh(at)agliodbs(dot)com> | 
|---|---|
| To: | "Richard Sydney-Smith" <richard(at)ibisaustralia(dot)com>, <pgsql-sql(at)postgresql(dot)org> | 
| Subject: | Re: Slow sub-selects, max and count(*) | 
| Date: | 2004-02-05 05:13:01 | 
| Message-ID: | 200402042113.01369.josh@agliodbs.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
Richard,
> The issue is with the speed ( or lackof it) that the procedure proceeds. 
Apparently it is the subselects that are the worst issue and I have tried to 
replace these. Also max() and count() refuse to use indexes. 
Max() and Count() cannot use indexes for technical reasons.   Browse through 
the archives of SQL, PERFORM, and HACKERS for about 12,000 discussions on the 
subject.
> Please, I am sure that there is a better way to do this. And 5 to 7 minutes 
to insert a day is really too slow. Each days import table contains about 
3200 records. Total table size for fsechist is about 2.5 million records.
Standard advice:
1) Where possible, use COPY and not INSERT for bulk imports.
2) Where COPY is not possible, group inserts into 1000-statement blocks and 
wrap them in a transaction.
3) Where safe, suspend all triggers, foriegn keys, and constraints on the 
table while inserting and re-apply them afterward.
-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Iain | 2004-02-05 06:42:03 | Re: Slow sub-selects, max and count(*) | 
| Previous Message | Richard Sydney-Smith | 2004-02-05 01:48:21 | Slow sub-selects, max and count(*) |