Performance tips on SqlDatasource

Discussion in 'Site Programming, Development and Design' started by maric01, Jun 7, 2012.

  1. Hello

    This is my situation : I have a webpage in asp.net with some gridviews. I have in that page a SQLDatasource with the select statement directly in my aspx pages. The select command is getting values from 1 table (I'm selecting 3 column, 1 int ID and 2 string). The select return around 4200 rows.

    That SQLDatasource is used in 2 gridview inside my aspx page (The SQLDataSource is binded to a DropDownlist inside the 2 gridviews).

    All operations are super slow on my webpage, even in other gridview on the page that are not using the sqldatasource with 4200rows. I did a test and putted TOP 10 in my select statement to see what was causing this slowiness. With the TOP 10, all operation in the page are super fast.

    Is there a way to optimize this ? What can I do to improve performance ? It is something insane to put 4200 rows in a dropdownlist ?

    The reason why i'm getting that much rows is because i'm building a line up for a hockey team and I choose players from the table containing all the poeple.

    Thanks for any tips or suggestions

    An happy Winhost customer ;-)
     
    Last edited by a moderator: Oct 14, 2015
  2. Yes it is.

    I can't really think of an efficient way to present 4,200 options to select from. Presenting them in a dropdown is not exactly user-friendly. Can't you just list them in columns with checkboxes?

    If I had a list that large to select from I wouldn't pull all those options from the database every time I needed to make a selection. I'd create a static page from that database - or at least a persistent page that only queries the db once - then use checkboxes to make the selections.

    There are a lot of ways to skin that cat, you have to figure out what works best for you.
     
  3. Actually, one gridview is for the line up of visiting team and another gridview is for the line up of the home team. I have a table of availables players (anyone can play in any team).

    when the user build the line up for the team, he choose a name from the dropdownlist (with the auto complete, it's pretty user friendly)

    I'm gonna try to find another way of doing that ;-):confused::rolleyes:;)
     
  4. If I'm illustrating it the way you do, this is the way I'd do it;

    First create index for the table so query can return result faster.

    Also if using gridview to return that much data, I'd use data paging.

    Or another way to do it is to create a separate panel contains A-Z alphabet where user can choose player's name based on their first initial. This way the query breaks into smaller bits and should be faster.
     

Share This Page