Re: sorting or temporary tables in execution plan?

From: -CELKO- <jcelko212_at_earthlink.net>
Date: Thu, 21 Aug 2008 15:02:58 -0700 (PDT)
Message-ID: <a7670bce-c582-4b79-b13d-c3af83bcf564_at_8g2000hse.googlegroups.com>


>> Is sorting of a temporary table a necessary step in an execution plan? <<

No, many products use hashing instead of sequential access and merges.

I would also have done this query like so in a conventional SQL engine built on top of a file system with indexes:

  1. Build temp table using (S.city = 'NY') -- should be pretty small subset, but if it is not indexed, you may have to scan the table.
  2. (SH.snum = S.snum) with an index on what looks like PK-FK. In some products that relationship would be in a linked list structure and be really fast.
  3. (P.pnum = SH.pnum) with an index

In short, the answer is that it all depends... Received on Fri Aug 22 2008 - 00:02:58 CEST

Original text of this message