SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Bulky Database Tables

rated by 0 users
This post has 8 Replies | 1 Follower

Top 50 Contributor
Posts 65
sukino Posted: 10-30-2007 4:04 PM

I am working on a program that could get the whereabouts of an item from the database. Problem is it is querying from a SQL table of 9 million records. Appreciate if some one could advise me the fastest/effective way to get the records.

 I tried to use sql stored procedure to insert into the temp table and then grab all the records from the temp table. But it took about 4 mins, which is not really acceptable. Sad

I am using asp.net 2.0 connecting to sql server 2000.

Top 25 Contributor
Posts 184
indices?

http://devpinoy.org/blogs/cruizer

Top 50 Contributor
Posts 65
There are indexes. I tried another method to reduce the records involved. Still I would be interested if anyone could suggest any method to retrieve bulky records.
Top 25 Contributor
Posts 184
but you're only retrieving one row...?

http://devpinoy.org/blogs/cruizer

Top 25 Contributor
Posts 157
Your query should be optimised to make full use of the indexes. Explain execution plans should be useful. I never encourage the use of temp tables if they can be avoided. Take a look at this link: http://www.sql-server-performance.com/articles/per/derived_temp_tables_p1.aspx. Of course, there are exceptions to it, especially when it comes to huge databases. So, check this link http://www.quest-pipelines.com/newsletter-v3/0602_D.htm out and see if the tips are useful.
Top 50 Contributor
Posts 65

cruizer:
but you're only retrieving one row...?

 It varies. Depending on the user's selection.

 

bronkman:
Your query should be optimised to make full use of the indexes. Explain execution plans should be useful. I never encourage the use of temp tables if they can be avoided. Take a look at this link: http://www.sql-server-performance.com/articles/per/derived_temp_tables_p1.aspx. Of course, there are exceptions to it, especially when it comes to huge databases. So, check this link http://www.quest-pipelines.com/newsletter-v3/0602_D.htm out and see if the tips are useful.
I will look at the urls. I did found out that temp tables slows down the performance, so I am really trying to avoid that. Thanks. I have decided to stick to my new idea. Consolidate the data using group and use triggers to update the quantity accordingly. At least the number of records is greatly reduced.
Top 10 Contributor
Posts 2,284
If the queries you are executing are based on column factors not being indexed, they do not take advantage of the indexes, and thus offer no benefit. Tuning indexes involves recognising how the table(s) get queried and looked up most of the time and which columns are used to determine what rows to return. Are the indexes indeed being put to good use? Take a look at the query execution plan for your stored procedures for estimates on to the cost of each query.

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 25 Contributor
Posts 157

Triggers is also something that I would advise to avoid. Try using transactions instead. Sometimes it is better to update a total field of the master table each time a detail record is inserted or updated. That said, it is better to test the performance since you have a large database.

Also, although indexes help, do ensure that your indexes are well maintained. Indexes on foreign keys can also be created, or tables can be de-normalised if necessary, for performance.

Top 25 Contributor
Posts 184
one should also evaluate the relative uniqueness of the values stored in an indexed column. for example if the field is a gender field with male/female values, it's not worth indexing. but if it's a first name column the values are likely to be more or less unique compared to each other so an index is useful in this case.

http://devpinoy.org/blogs/cruizer

Page 1 of 1 (9 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems