select price,itemid, FROM `articles` where itemid='56606' OR
itemid='51014' OR itemid='11080' OR itemid='25919' OR itemid='48357' OR
itemid='80651' OR itemid='62374' OR itemid='7652' OR itemid='29208' OR
itemid='80473'
... another 100 ArticleIDs...
What is the fastest way for the DB to parse this query:
This way
WHERE itemid IN ( 56606, 51014, 11080, 25919 )
or is there a better/faster way to save resources?
Thanks!
Hello,
I'm no export but what does a "EXPLAIN SELECT ...." show for each statement ?
Just place the EXPLAIN keyword in front of your SQL and run it.
regards,
Johannes Keßler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (GNU/Linux)
iEYEARECAAYFAkr5QwIACgkQE++2Zdc7EtesMQCgj49vfgNPZnUfNv4gwdqpJ5pM
3DIAoKfHYCDxyUWEEqs1gBeTKT04rwZT
=4RgX
-----END PGP SIGNATURE-----
>
> [...] ... another 100 ArticleIDs...
>
>What is the fastest way for the DB to parse this query:
>
>This way
> WHERE itemid IN ( 56606, 51014, 11080, 25919 )
>
>or is there a better/faster way to save resources?
Darn! That's what I would call "need for speed".
You already have it all spelled out for MySQL with
"WHERE itemid IN ( 56606, 51014, 11080, 25919 )", which will be parsed
in less than a millisecond, and you wonder if it can be parsed any
faster?
I would only want to wonder if the query finds and returns the results
efficiently. The parser would probably be the smallest (if at all)
problem.
--
Erick
No ;)
But sometimes there are Gurus that write magic words like use MAGIC
instead of Select ...
and got the results in "negativ" - Time...
So: As an sql-beginner, iam happy with your answer
Thanks!
Normally the parsing of the SQL code is negligible part of the
query execution time. I'd expect the second variant with IN to
parse a little faster. The execution plan for both variants
should be the same anyway. At least with a 5.x version.
You can profile this!
http://dev.mysql.com/doc/refman/5.1/en/show-profiles.html
XL