Note that there are some explanatory texts on larger screens.

plurals
  1. POEvaluate SQL where clause in c# without SQL Server
    primarykey
    data
    text
    <p>I have a large set of conditions (I don't know them ahead of time) that I need count against a relatively small SQL Server table (&lt; 10,000 rows). Each condition is in the form of a SQL where clause. Currently, I build a complete sql statement in the form of "select count(*) from some_table where " + Where_Clause; and I let SQL Server return the count to me. I do this in a loop to get all the counts I need for all the various conditions. </p> <p>I'm looking for ways to speed this up when I have dozens or hundreds of counts I need to run. I don't know the statements ahead of time. Some will select the whole table, some may not select any rows. I've tried the following solutions:</p> <ol> <li>Issuing the queries in parallel - saw minimal improvement even when not doing any locking </li> <li>Writing them as complex counts on case statements so I can run multiple where clauses in one statement</li> <li>Passing many queries together as UNIONs and getting the results back as one result set</li> </ol> <p>None of these options have had a fantastic improvement in runtime (sometimes it would run more slowly) and with the added complexity, I don't feel any of them are worth it. </p> <p>My question is: I can very quickly load the entire table into a DataTable object just by running one "select *" against it. If I had the whole table in memory, is there a way to run counts against it without going back and forth to SQL Server? I'm hoping to cut out the overhead of the: network, I/O, locking, etc.</p> <p>The most complex where clause would be something like:</p> <pre><code>a=1 or b in (2,3) or c&lt;4 or d like '%5' or substring(e,2,1)='z' </code></pre> <p>So it's not trivial and supporting as much as possible of T-SQL would be ideal, but I don't think DataTable's .Select() method supports this OR is it very fast. So given a table of data in memory, can I could rows using T-SQL syntax very fast (or in parallel)?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload