SQLite Forum

union vs left join for select
Login
Run the queries with .eqp on and see which generates the most efficient plan.

Since you are using the DISTINCT qualifier I would suspect that you would have better results by having correct schema declarations (indexing and collation).

Once you have the correct schema then I would suspect that something like the following would be most efficient:

```
select name
  from (
        select nameid
          from allnouns
        union
        select nameid
          from allverbs
       )
  join names
    on name == nameid
;
```

which also happens to be the one that most closely expresses your unspoken problem definition (ie, it is what your other statements appear to be trying to accomplish) and gives the optimizer the widest latitude to generate an optimum plan.

In any case, running the queries against the data and/or reading the generated plan (via .eqp on or explain query plan) would be highly enlightening.