On 7/12/2011 3:39 PM, Bart Smissaert wrote:
> Joining a large table (ENTRY_ATTRIBUTES) and a small table
> (BPNewENTRY) and putting the resulting records
> in a third table, BP3. Large table may have a few million records and
> small table a few hundred records.
> The join field is called ENTRY_ID in both tables and this has a
> non-unique index in the large table and is the integer primary key
> in the small table. Data type is integer in both these fields.
>
> This is the SQL:
>
> INSERT OR REPLACE INTO BP3
> (ENTRY_ID, NUMERIC_VALUE, UNIT)
> SELECT EA.ENTRY_ID, EA.NUMERIC_VALUE, EA.TYPE_SPECIFIC_INFO
> FROM
> ENTRY_ATTRIBUTES EA INNER JOIN BPNewENTRY E ON
> (EA.ENTRY_ID = E.ENTRY_ID)

Try   ON (EA.ENTRY_ID = +E.ENTRY_ID) . The unary plus should suppress 
the index on BPNewENTRY, and force SQLite to turn the execution around: 
scan BPNewENTRY and look up in ENTRY_ATTRIBUTES using index.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to