Hi,

> Now as expected it's an dependent subquery and makes use of the index on
> document_id. BUT: If we change the "SELECT id" in the subquery to
> "SELECT document_id" or "SELECT 1", we get:
> 
> *************************** 1. row ***************************
> [...]
> *************************** 2. row ***************************
>            id: 2
>   select_type: DEPENDENT SUBQUERY
>         table: file
>          type: ref
> possible_keys: document_id
>           key: document_id
>       key_len: 2
>           ref: djbdms.t1.id
>          rows: 1
>         Extra: Using index
> 
> Note the "Using index"!
> 
> I played around with it and it really makes a huge performance
> difference - in my case the file table contains a lot of large blobs, is
> fragmented and I'm running weak hardware. Seems as if "using index" is
> not just (irrelevant or wrong) EXPLAIN output but is what is really
> going on?

>From the manual :
- Using index

The column information is retrieved from the table using only
information in the index tree without having to do an additional seek
to read the actual row. This strategy can be used when the query uses
only columns that are part of a single index.

So you should save an extra seek from the disk I guess.


-- 
Pooly
Webzine Rock : http://www.w-fenec.org/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to