Re: Query Help
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/27/04
- Next message: Hugo Kornelis: "Re: output in one row?"
- Previous message: Darth: "Help with sql statement"
- In reply to: Mario Splivalo: "Re: Query Help"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Aug 2004 13:28:08 +0200
On Fri, 27 Aug 2004 09:54:55 +0000 (UTC), Mario Splivalo wrote:
(snip)
>to extract the data from the tables i relay heavy on views.
>But, for some particular querries it turns out to be MUCH faster to do the
>SELECT * INTO #tempTbl FROM vw_someView1, etc... and then do the joins and
>whatever on the #tempTBL and stuff. On the data set that contains like 30k
>rows in master table and around 500k rows in the details table the speed
>improvements are: from around 2 minutes down to 15 seconds.
Hi Mike,
Good to know that. I'll keep it in mind in case I encounter similar
problems with views.
Funny though that the optimizer doesn't consider a plan where the view is
materialized first and then reused multiple times. It looks like an easy
win. I encountered similar situations with derived tables that appeared
multiple times in one query, or when updating multiple columns using ANSI
standard update syntax (ie without FROM clause) - in all these situations,
the subquery was EXACTLY the same (except for the selected column in the
update scenarios), yet the optimizer chose to execute it multiple times.
I'd understand it if I had used different queries, but I think that the
optimizer should be able to compare subqueries used in a query, find which
are equal (possibly excluding the select list in the comparison) and then
consider an execution plan where the subquery gets evaluated only once.
Actually - does anybody know if this behaviour is implemented in (or
planned for) Yukon?
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Hugo Kornelis: "Re: output in one row?"
- Previous message: Darth: "Help with sql statement"
- In reply to: Mario Splivalo: "Re: Query Help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|