On Sat, 2005-04-23 at 14:25 +0200, Pierre D. wrote:
> I'm trying some "simple" query. The first query is "Whose file is it ?"
> Here is my first SQL query for that (ran with the sqlite3 command) :
> sqlite> SELECT p.name FROM packages p, files f WHERE f.pkgid=p.pkgid AND 
> f.filename="/usr/bin/gcc";

Reverse the order of the tables in the FROM clause.  Like this:

   SELECT p.name FROM files f, packages p WHERE ...

Then make sure you have indices on files.filename and
packages.pkgid.  If you do those two things, the query above
should run in O(logN) time.  Without those changes, the
execution time should be O(N^2).
-- 
D. Richard Hipp <[EMAIL PROTECTED]>

Reply via email to