473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

View behaviour in join

Hi Everybody,

I have a complex view, that includes a "group by" clause. I'm trying
to join this view with a table, in a very simple query.

The problem is that the optimizer is not using the table data as input
for the view (I expect this because I have arguments for the table,
but not for the view), but executing the view in a different step and
then joining to the table by a merge/hash join. This is obviously very
slow.

I tried to force nested loops by using hints but it still doesn't use
the table data as input.

Has anybody ever seen this?
Thanks in advance...
Jul 20 '05 #1
3 2412
Marcelo Noga (no**@mpsinf.com.br) writes:
I have a complex view, that includes a "group by" clause. I'm trying
to join this view with a table, in a very simple query.

The problem is that the optimizer is not using the table data as input
for the view (I expect this because I have arguments for the table,
but not for the view), but executing the view in a different step and
then joining to the table by a merge/hash join. This is obviously very
slow.

I tried to force nested loops by using hints but it still doesn't use
the table data as input.


Theory has it that the view is just a macro which is just pasted into
the query, although it does not always really work like that.

But I think you need to post you view and query, so we know what you are
talking about.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
>> ... executing the view in a different step and then joining to the
table by a merge/hash join. <<

Most optimizers will do it this way because of the GROUP BY. Can you

1) use a derived table to fool the optimizer.

2) expand the view and see if you can move the GROUP BY to the outer
query
Jul 20 '05 #3
Thank you all, but I've already found a solution to it.

I don't know why, but changing the regular join to an outer join (with
the view being the inner "table") made the optimizer to work fine.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John | last post by:
When I create a view consisting of an inner join between a view and a table the columns refernced in the the view are returned incorrectly, example select id.itemcode, id.description,...
3
by: Mike | last post by:
I have a view that will return say 5000 records when I do a simple select query on that view like. select * from vw_test_view How can I set up my query to only return a certain # of...
12
by: Neil | last post by:
I previously posted re. this, but thought I'd try again with a summary of facts. I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that is linked to the database via ODBC...
1
by: jtwright | last post by:
I've got a view that creates a parent child relationship, this view is used in Analysis Services to create a dimension in a datastore. This query tends to deadlock after about 10 days of running...
1
by: \(Bradley | last post by:
In an A2000 ADP I cannot edit data in an MS-SQL2000 view that has a simple JOIN in it. However I can edit the data in the same view if I open it in A2003 or SQL Query Analyser/etc. I understand...
2
by: elein | last post by:
Yes, I vacuumed. Reproduced on both 7.3.2 and 7.5. Brain dead java beans want order by clauses in views that they use. my view is: select .... from bigtable b left join lookuptable l order...
1
by: rcamarda | last post by:
I was looking through our vendors views, searching for something I needed for our Datawarehouse and I came across something I do not understand: I found a view that lists data when I use it in...
0
by: MarsLandingParty | last post by:
Hello All, I have managed to create a partitioned view ona large table - the view is updateable, and looking at the execution plan, only the relevant table is queried. The partition is by...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.