SQLite Forum

How to speed up this query?
Login
Well, in 3.32.2 and in 3.31.1, when I make up tables to match meta and trace, and run an EQP, it gives me what you're looking for:

QUERY PLAN
|--SEARCH TABLE meta AS a USING INDEX metadata_idx_05 (traceid=? AND itemid=?)
|--SEARCH TABLE trace AS t USING COVERING INDEX trace_idx_03 (datasetid=?)
`--CORRELATED SCALAR SUBQUERY 1
   `--SEARCH TABLE meta2 USING COVERING INDEX sqlite_autoindex_meta2_2 (parameter=? AND value=?)

So some comments and questions:
What are the full create statements for data and trace?
Have you run analyze?
Were there any changed compile-time options if you compiled it yourself?

"primary key unique" is redundant, and in older versions would actually create 2 indexes, one for primary key, and another for unique.

The unique constraint in the create table makes an index on (parameter, value), so you don't need to create a separate one. (Though adding it may have just been from your experimenting)