-1

We have a 4 column data grid display on a page. I would like to perform a query based on each of the values within each cell of the grid i.e. 4 queries for each row.

This is so I can populate the cell with count of records in db that matches that value.

When each row gets populated by jqgrid, it fires off an ajax call for each cell.

I think it's a very bad idea since I have already discovered the browser limits the number of ajax calls to the same server.

Are there similar limits for ado.net?

I would like to batch these queries together so I do fewer calls to the db, is this what you would do?

How would you approach this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ageis
  • 2,221
  • 4
  • 22
  • 34
  • You are doing something wrong, or you are not telling us Something. Even an Crossapply on 30 column 2k row do not have this number of querry. – Drag and Drop Jul 06 '18 at 09:46
  • Either you create a [mcve], showing bogus data and querry so we can understand the spirit and tell you why you are doing duplicate work or how we can factorise those querry. – Drag and Drop Jul 06 '18 at 09:47
  • If i display a grid either the querry give me all the result and no more querry are needed or it give me enought data to make me count, and compute in background the result I need – Drag and Drop Jul 06 '18 at 09:50
  • Why not a single Ajax call that contain the required information for each cell? And then, on the server side only 4 queries running in parallel. – Jesús López Jul 06 '18 at 09:50

2 Answers2

0

You could combine your AJAX calls into one, the resulting object contains an array, or multiple properties for each result set, and then you run your SQL in parallel on the server.

Check out this QA for how to use options on how to use TPL and SQL.

Parallel.Foreach SQL querying sometimes results in Connection

Phil
  • 2,315
  • 2
  • 18
  • 26
0

me would suggest you to select the associated id data in the first request and populate the values in the UI.

You could either use join or left join in your first query based on your requirement and architecture and fetch the specific column value/ count(id) ( Here you mentioned as the count of records ).

Neethu
  • 284
  • 2
  • 4