Harald: warum benutzt mysql den index nicht?

Hi,

EXPLAIN SELECT FILE , count(
FILE ) AS anzahl, data, title, max( wert )
FROM tabelle
USE INDEX (
FILE )
WHERE datum >= '2005-02-13' AND datum <= '2005-02-13'
GROUP BY FILE ORDER BY anzahl DESC
LIMIT 1 , 20

schmeiß raus:

table: tabelle
type: index
possible_keys: NULL
key: file
key_len: 255
ref : NULL
rows: 94136
Extra: Using where; Using temporary; Using filesort

Der Index von "file" ist aber gerade mal 16805 rows groß.
Ein "force index" bringt auch nix. Warum macht mysql das?

Gruß
Harry

  1. Hi,

    EXPLAIN SELECT FILE , count(

    [...]

    WHERE datum >= '2005-02-13' AND datum <= '2005-02-13'

    [...]

    Warum macht mysql das?

    weil ein Index über etwas anderes als das Datum herzlich wenig bringt.

    Cheatah

    --
    X-Self-Code: sh:( fo:} ch:~ rl:° br:> n4:& ie:% mo:) va:) de:] zu:) fl:{ ss:) ls:~ js:|
    X-Self-Code-Url: http://emmanuel.dammerer.at/selfcode.html
    X-Will-Answer-Email: No
    X-Please-Search-Archive-First: Absolutely Yes
    1. Hi,

      EXPLAIN SELECT FILE , count(
      [...]
      WHERE datum >= '2005-02-13' AND datum <= '2005-02-13'
      [...]
      Warum macht mysql das?

      weil ein Index über etwas anderes als das Datum herzlich wenig bringt.

      Danke für die Antwort.
      Aber ich versteh es nicht! Ich würde es verstehen, wenn ich nicht nach "file" gruppieren würde.

      Gruß
      Harry