Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friend,

I am researching on "Query Optimization for Dynamically generated Join Queries in Sql-server".

Suppose I have huge database which contains 10-15 tables containing 1000 of users .When I create join query dynamically we don't to the best order in which we can join so that we get the output in optimized way or in minimum time.

Consider a scenario:
Suppose I want to create join query which requires 8-10 tables (out of 10-15 tables present in database) containing thousands of records.So how can we arrange the sequence of joining the table dynamically in join query so that we get the optimized result.

Is there any way to breakdown the query and join the results of those queries or some other way which can give us best result for dynamically generated join in sql-server or some dynamic way through which we can decide the best order of joining the tables.

Please reply me...

Thank u ...
Posted

Hi Alia,

I assume that the programmer of the dynamic query would have sufficient knowledge about all the tables.

Now, as far as the generating dynamic query is concerned, the joins are decided based on the output fields of the query as well as the input parameters of the query.

The input parameters play an important role here.. You can create dynamic select statement based on the input parameter and then join the tables in the order you would think is optimised again based on whether the input parameter is passed in or not...

I understand that this is quite a generalized answer but so is your question. If you could give us a better understanding on the table structures and indexes on the table and the amount of data in the table as well as the input and output parameters, someone can better answer.

Hope this helps.

Regards,
Nayan
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900