From: Reindl Harald Date: February 12 2012 10:40pm Subject: Re: Indexed Query examining too many rows! List-Archive: http://lists.mysql.com/mysql/226785 Message-Id: <4F383FF9.50804@thelounge.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEA2CF6E7F1EC48F02DBDF616" --------------enigEA2CF6E7F1EC48F02DBDF616 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Am 12.02.2012 23:25, schrieb Cabbar Duzayak: > Hi All, >=20 > I have a table with a btree index on its searchKey column, and when I > send a simple query on this table: >=20 > explain select * from DataIndex where (searchKey like 'A%') order by > searchKey limit 10 >=20 > rows is returning 59548 and it tells me that it is using the searchKey = index. >=20 > Also, a select count(*) on this table returns 32104 rows, i.e. >=20 > select count(*) from DataIndex where searchKey like 'a%' -> gives > 32104 as its result >=20 > Am I doing something wrong here? Given that the searched column is > indexed, shouldn't it examine way less rows? LIKE does not benefit from keys! --------------enigEA2CF6E7F1EC48F02DBDF616 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk84P/kACgkQhmBjz394Ann+aQCeK7vnuEAKymCez7LTU5Vp3h6X 7xsAn0i42N5tbT/SX6KLbdZkBt9kRqmt =825Q -----END PGP SIGNATURE----- --------------enigEA2CF6E7F1EC48F02DBDF616--