Suppose I execute a query in MySQL (or PostgreSQL), let's say:
SELECT * FROM USER WHERE age = 20;
Does the database engine parse and compile the query/statement each time I execute it? Or does it hold some cache of the previous statements/queries?
If it has a cache mechanism, does it treat the following two queries differently?
/* first query */
SELECT * FROM USER WHERE age = 20 AND name = 'foo';
/* second query */
SELECT * FROM USER WHERE name = 'foo' AND age = 20;
I'm asking that because I'm using some tool for generating the SQL queries in my code, that doesn't consistent with the order of the conditions in the queries. I just want to be sure that this behavior doesn't effect my database performance.
Thanks