SQL Query Performance, Large, where statements and queries

I am wondering which method is more efficient for retrieving data from a database.

ex. One part of my application can have over 100 objects. I now have a setup to query the database twice for each object. This part of the app is updated periodically, say every 2 minutes, and this app will probably end up installing 25-30 pcs. I think this is a large number of select statements from the database and I am thinking about trying to optimize the procedure. I need to output information from multiple tables and both queries are using join statements.

Would it be better to rewrite the queries so that I run queries twice per update instead of 200 times? For example, using a big where clause to include each object, and then doing data processing outside of the object rather than inside each object?

Using SQL Server, .net No indexes in tables, database size less than 10-5%

+1


a source to share


2 answers


All other things being equal, many multi-line statements are usually worse than multiple multi-line statements.



show the actual code and get better answers.

+3


a source


The default answer for optimization should always be: don't optimize until you can demonstrate that you need it. Next, after you've demonstrated the need for it, and an alternative approach: try both ways to determine which is faster. You cannot predict which will be faster, and we certainly cannot. KM's answer is good - fewer requests tend to be better, but the way to know is to check.



+2


a source







All Articles