user1263746
user1263746

Reputation: 6308

MySQL : /*! */ interpretation

I am reading a MySQL tutorial and I encountered this :

SELECT /*! SQL_NO_CACHE */ user FROM users;

Why is the optimization hint SQL_NO_CACHE is enclosed with :

/*!    */

I looked up on google but I simply failed to get any result.

Upvotes: 2

Views: 140

Answers (2)

mjuarez
mjuarez

Reputation: 16834

The idea is to make the query more portable. That way, only MySQL will see it, not whatever language/connection-pool/driver you're using, trying to validate it, and failing, since it's not standard SQL.

Upvotes: 3

Vasilis Lourdas
Vasilis Lourdas

Reputation: 1179

These are hints to MySQL, like the one you mention, it says not to cache the result. These hints are written this way, so that they interpreted by MySQL only (try to run the query in another database).

Upvotes: 3

Related Questions