Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does having more attributes in a table reduce performance?

Tags:

c#

sql

asp.net

So far I am quite comfortable working with C# windows application. I am about to shift to Asp.net to develop a website. The requirement has made me to put around 50 columns in a single table. I know this concept of breaking it into small tables using normal forms.

I tried googling, but dint get much results. I need to know if my table with 50 attributes would decrease performance of my web application? Can somebody suggest me about this.

like image 989
Srikanth V M Avatar asked Jan 21 '10 12:01

Srikanth V M


People also ask

Does number of columns in table affect query performance?

Does the number of columns on a table have impact on performance? Yes, more number of columns, more metadata is needed. We suggest to use least number of columns needed, ideally < 100 columns on a table if possible.

Does the number of tables affect database performance?

The number of tables doesn't matter so much as: What queries you're running - you aren't likely to be querying all 200 within a single query. The overall query load on the system at any given point in time.

How can I speed up my large table queries?

Use temp tables Speed up query execution in your SQL server by taking any data needed out of the large table, transferring it to a temp table and join with that. This reduces the power required in processing.

How many columns should a table have?

There is no precise guidance. A table could be as little as one column or as many as the max, 1024. However, in general, you'll probably see no more than 10-15 columns in a table in a well normalized database.


1 Answers

Well, if you bring them all back you certainly have the network costs (data transfer between the db and your .NET code) and materialization costs (creating the object / DataTable representation in your DAL), so then you would definitely have some costs. Either way you have to consider the page size of the database.

But perhaps the key thing is: do you need all the data? If so, there is only so much you can do. Using multiple tables and introducing joins will also impact performance.

In most cases though, and especially ASP.NET, the most important figures are things like:

  • what volume data actually goes to the client application? (could you use paging / ajax /. etc?)
  • what data is stored in session?
  • how many round-trips do you do between client and app-server?

since bandwidth and latency between your app-server and the client tends to be the pinch-point. Measure things; make sure you are targetting the right performance concerns.

Also, ASP.NET has a reputation for not being shy about storing more than you expect in things like view-state; keep an eye on this, or switch to a more light-weight model like ASP.NET MVC.

like image 86
Marc Gravell Avatar answered Sep 30 '22 18:09

Marc Gravell