Hello.

I have a question about SQLite join-mechanisms. Let me explain with an
example.

I have the follow table.
CREATE TABLE a(
  word_id INTEGER,
  doc_id INTEGER
);

CREATE INDEX "a_index1" ON "a"(
"doc_id"  ASC
);

CREATE INDEX "a_index" ON a (
  "word_id" DESC
);

And how can SQLite do an optimized join of the follow query
SELECT
   a.doc_id
FROM
   a, a as a1, a as a2
WHERE
   a.doc_id = a1.doc_id and a1.doc_id = a2.doc_id  and
   a.word_id = 1 and a1.word_id = 2 and a2.word_id = 4
LIMIT 0,20

What the example do is find the doc_id that has word_id 1,2 and 4.
And suppose that there is:

  - 40000 docs with word_id 1
  - 50000 docs with word_id 2
  - 353500 docs with word_id 4


What i am searching is a optimized way to join, i mean, the algorithm. And I
think SQLite has a great performance with joins.

Thank to all.

--
Cesar Rodas
http://www.cesarodas.com/
Mobile Phone: 595 961 974165
Phone: 595 21 645590
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to