Jens-Heiner Rechtien wrote:
> SELECT count(*)
> FROM spacefavorite, album_asset, albums, assetProfileLinks, 
> avatarCacheReferences,
>      cacheReferences, comment, conflicts, coreInfo, coreMD5, errors, flags,
>      importSource, missingBinariesOnOz, profileRegistration, quota_exceeded,
>      renditionRevisions, space, space_album
> LIMIT 1;

The "LIMIT 1" does not have any effect because COUNT() returns only one row.

> this query will busy hang and never return.

It would return if you just waited long enough.

This is how your query would be implemented for five tables:

  sqlite> explain select count(*) from a, b, c, d, e;
  addr  opcode         p1    p2    p3    p4             p5  comment
  ----  -------------  ----  ----  ----  -------------  --  -------------
  0     Init           0     27    0                    00  Start at 27
  1     Null           0     1     1                    00  r[1..1]=NULL
  2     OpenRead       0     3     0     0              00  root=3 iDb=0; a
  3     OpenRead       1     2     0     0              00  root=2 iDb=0; b
  4     OpenRead       2     4     0     0              00  root=4 iDb=0; c
  5     OpenRead       3     5     0     0              00  root=5 iDb=0; d
  6     OpenRead       4     6     0     0              00  root=6 iDb=0; e
  7     Rewind         0     18    0                    00
  8       Rewind         1     17    0                    00
  9         Rewind         2     16    0                    00
  10          Rewind         3     15    0                    00
  11            Rewind         4     14    0                    00
  12              AggStep0       0     0     1     count(0)       00  
accum=r[1] step(r[0])
  13            Next           4     12    0                    01
  14          Next           3     11    0                    01
  15        Next           2     10    0                    01
  16      Next           1     9     0                    01
  17    Next           0     8     0                    01
  18    Close          0     0     0                    00
  ...
  23    AggFinal       1     0     0     count(0)       00  accum=r[1] N=0
  24    Copy           1     2     0                    00  r[2]=r[1]
  25    ResultRow      2     1     0                    00  output=r[2]
  ...

Please note that "," is just the short form of "CROSS JOIN", so this
query is implemented as lots of nested loops.

> admittedly nonsensical

You could speed up this query by deleting the contents of all tables ...


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to