[thesite] database: content table

rudy r937 at interlog.com
Sat May 26 00:16:15 CDT 2001

> I was under the impression that subqueries were never
> the best way to go performance-wise. Is this not correct?

not as an absolute rule, no

in fact most subqueries (at least, the correlated kind) get parsed by the
optimizer into joins

some subqueries are indeed the fastest way to do something

for example

    select contentname, datemod
     from content
      where datemod >=
          (select max(datemod) from
              from content
                  where userid=5)

this gets all the articles added after the last article added by djc

the subquery (inner query) is not related to the outer query -- it is not
correlated, i.e. its result is independent of the rows of the outer query,
consequently it can be retrieved first, the result stored in a variable,
and compared to datemod in each row of the outer table


More information about the thesite mailing list