On Sat, 2003-02-08 at 04:48, greg@turnstep.com wrote:
> > Greg Sabino Mullane (in the other thread) suggested the following alternate,
> > but it ran slightly slower on my machine than the original.
> >
> > SELECT id, date, value FROM sample a WHERE date <='2003-01-01' AND oid =
> > (SELECT oid FROM sample WHERE id = a.id AND DATE <='2003-01-01' ORDER BY
> > date DESC LIMIT 1)
> > ORDER BY id;
>
> You should check this again. There is no way that my query is slower, as
> long as you have an index on the "date" column and have run an ANALYZE on
> the "sample" table.
Wouldn't there need to be an index on OID for your query to be fast?
Cheers,
Andrew.
--
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Survey for nothing with http://survey.net.nz/
---------------------------------------------------------------------