Re: [SQL] Slow sub-selects, max and count(*)

2004-03-29 Thread Josh Berkus
Greg, > Please don't confuse the issue by throwing Max() and Count() into the same > basket. When on earth is that post of mine from? Seems like it's several months, if not a couple of years, old. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of br

Re: [SQL] Slow sub-selects, max and count(*)

2004-03-27 Thread Greg Stark
Josh Berkus <[EMAIL PROTECTED]> writes: > 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 don't confuse the issue by throwing Max() and Count() into the same basket.

Re: [SQL] Slow sub-selects, max and count(*)

2004-02-05 Thread Josh Berkus
Richard, > Ian you suggested a simular problem was solved using "exists" rather than "in". I am not sure how the use differs. I have tried to include it in option 4 below. Hmmm ... this piece of advice is dated; with PG 7.4, IN() queries should be plenty fast. If you're using 7.3 or less, th

Re: [SQL] Slow sub-selects, max and count(*)

2004-02-05 Thread Bruno Wolff III
On Thu, Feb 05, 2004 at 15:53:08 +0800, Richard Sydney-Smith <[EMAIL PROTECTED]> wrote: > Trial Solutions: > > 1) delete from fsechist where hist_q in (select hist_q from fsechist, > temp_shareprices where hist_tick = ticker and dte = hist_date); Don't you want: delete from fsechist where hist

Re: [SQL] Slow sub-selects, max and count(*)

2004-02-05 Thread Richard Sydney-Smith
Thanks Josh and Ian,   narrowing the problem down. The really slow line is the one where I try and remove potential duplicates. It does not look at the indexes.   Point on using copy rather than insert is taken. I use copy to load to a temp file so I can test the data and alter certain value

Re: [SQL] Slow sub-selects, max and count(*)

2004-02-04 Thread Iain
Thursday, February 05, 2004 10:48 AM Subject: [SQL] Slow sub-selects, max and count(*) I have a procedure ( included below with table definition) to import end of day quotes into a table fsechist.   The issue is with the speed ( or lackof it) that the procedure proce

Re: [SQL] Slow sub-selects, max and count(*)

2004-02-04 Thread Josh Berkus
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 thr

[SQL] Slow sub-selects, max and count(*)

2004-02-04 Thread Richard Sydney-Smith
I have a procedure ( included below with table definition) to import end of day quotes into a table fsechist.   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 c