On Mon, Aug 18, 2003 at 11:53:29AM -0700, Michael S. Fischer wrote:
>
> I'm using MySQL 4.0.13 for a web application, and one of my queries
> is sufficiently complex such that it might take several seconds to
> return the results to the user. I'd like to return a "please wait"
> page if the query is not already in the cache. Is there a way (or a
> proposed way) of doing a query, for example:
>
> SELECT in_query_cache("STATEMENT") ? (Result: 0 if not in cache, 1 if
> in cache)
No, there's no way to do that today.
Perhaps you could tell us more about the queries that take too long.
Maybe there are some things you can do to reduce that time?
> Also, right now, it appears that the query cache treats as a cache
> miss a statement whose only difference from a previously-cached
> statement is a LIMIT clause.
Actually, *any* difference includ whitespace consittutes a new query
as far as the cache is concerned. It simply hashes the query sttring
without any real processing (other than looknig for the query cache
hints).
> And so, it's actually faster for the application to issue a query
> without a LIMIT clause, and then limit the results by way of
> accessing only certain elements in the resulting array, than it is
> to have MySQL do it for me.
Again, it'd be helpful to post some details about what you're trying
to do. Someone may find a faster soluiton.
> I propose that the cache be tunable so that MySQL can cache the
> whole result set such that statements that vary only in their LIMIT
> clauses are all treated as cache hits.
That'd be non-trivial change to the current cache implementation.
> RAM is cheap, so it seems to be a reasonable suggestion.
If RAM is cheap, why not add enough RAM to your server so that your
slow queries are less slow?
Or are they CPU bound?
Jeremy
--
Jeremy D. Zawodny | Perl, Web, MySQL, Linux Magazine, Yahoo!
<[EMAIL PROTECTED]> | http://jeremy.zawodny.com/
MySQL 4.0.13: up 17 days, processed 875,868,653 queries (588/sec. avg)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]