Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed for long and dynamic select query/view sqlite
    primarykey
    data
    text
    <p>I have a need to generate a long select query of potentially thousands of <code>where</code> conditions like <code>(table1.a = ? OR table1.a = ? OR ...) AND (table2.b = ? OR table2.b = ? ...) AND....</code></p> <p>I initially started building a class to make this more bearable, but have since stopped to wonder if this will work well. This query is going to be hammering a table of potentially 10s of millions of rows joined with 2 more tables with thousands of rows.</p> <p>A number of concerns are stemming from this:</p> <p>1.) I wanted to use these statements to generate a temp view so I could easily transfer over existing code base, the point here is I want to filter data that I have down for analysis based on selected parameters in a GUI, so how poorly will a view do in this scenario?</p> <p>2.) Can sqlite even parse a query with thousands of binds?</p> <p>3.) Isn't there a framework that can make generating this query easier other than with string concatenation?</p> <p>4.) Is the better solution to dump all of the WHERE variables into hash sets in memory and then just write a wrapper for my DB query object that gets <code>next()</code> until a query is encountered this satisfies all my conditions? My concern here is, the application generates graphs procedurally on scrolls, so waiting to draw while calling <code>query.next()</code> x 100,000 might cause an annoying delay? Ideally I don't want to have to wait on the next row that satisfies everything for more than 30ms at a time.</p> <p>edit:</p> <p>New issue, it came to my attention that sqlite3 is limited to 999 bind values(host parameters) at compile time.</p> <p>So it seems as if the only way to accomplish what I had originally intended is to</p> <p>1.) Generate the entire query via string concatenations(my biggest concern being, I don't know how slow parsing all the data inside sqlite3 will be)</p> <p>or</p> <p>2.) Do the blanket query method(<code>select * from * where index &gt; ? limit ?</code>) and call next() until I hit what valid data in my compiled code(including updating index variable and re-querying repeatedly)</p> <p>I did end up writing a wrapper around the QSqlQuery object that will walk a table using index > variable and limit to allow "walking" the table.</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