Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a very, very very difficult problem to solve <strong>in a generic way</strong>. There's one kind of software that does this all day long, and it's called an <strong>SQL query optimizer</strong>: that bit of code present in every single modern SQL engine will take a look at what you want (query), then take a look at the indexes available for your data, the selectivity of available indexes and it has to figure out the optimal way to use all that to give you your result set. Just to prove the problem is very difficult, the SQL query optimizer sometimes fails and produces visibly inefficient plans.</p> <p>I'm pretty sure you don't want to implement an full-fledged query optimizer so here are some tips on how to make your queries fast enough:</p> <p>(1) Select some fields that are frequently used in your queries and set up indexes on them. Those fields need to provide good selectivity: Don't index on a "boolean" value, you'd just loose time traversing complex binary search structures when you might just as fast (or faster) look at the whole list!</p> <p>(2) For every given query select <em>ONE</em> single index to pre-filter the data and the apply all other filters one-by-one (without optimization).</p> <p>In your example: Create indexes on the "A" and "B" fields. "C" seems to be a function so that's impossible to index. "IsRoot" seems to return an Boolean, that's not worth indexing.</p> <p>The data structures to use for your data depend entirely on your data. If performance is critical implement several and do tests. If it's not critical just your favorite list sorting algorithm and be done!</p>
 

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