List:General Discussion« Previous MessageNext Message »
From:Mr. Shawn H. Corey Date:July 24 2008 1:10pm
Subject:Re: how to optimize: max(timetstamp) where a.foo=b.foo ?
View as plain text  
On Thu, 2008-07-24 at 14:49 +0200, walter harms wrote:
> hi list,
> i have tables that look like this( <10.000 entries) :
> 
> id,
> timestamp,
> value
> 
> 
> to get the latest value for each id i have queries like:
> 
> select * from tab A where timestamp = (select max(timestamp) from tab B where
> B.id=A.id) group by id ;
> 
> on a fast system it takes round 4 sec to complet, but since this is done requlary it
> slows down to much.
> the same query takes on a informix system an a slower computer next to nothing.
> 
> any ideas ?
> 
> re,
>  walter
> 
> 
> 

Run EXPLAIN for the statement on both systems and examine the results.


-- 
Just my 0.00000002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."

"Perl is the duct tape of the Internet."
        Hassan Schroeder, Sun's first webmaster

Thread
how to optimize: max(timetstamp) where a.foo=b.foo ?walter harms24 Jul
  • Re: how to optimize: max(timetstamp) where a.foo=b.foo ?Mr. Shawn H. Corey24 Jul
  • Re: how to optimize: max(timetstamp) where a.foo=b.foo ?Peter Brawley24 Jul
    • Re: how to optimize: max(timetstamp) where a.foo=b.foo ?walter harms24 Jul