Re: Is Temporary table right approach

From: Date: Wed, 15 Apr 2009 09:09:35 +0000
Subject: Re: Is Temporary table right approach
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-46112@lists.php.net to get a copy of this message
I think a temporary table is likely to be the right approach. I have some times found massive seed improvements by caching a result set inside a temporary table. If the data in the table is just ids (ie, just one field), you could get an additional speed bump by rewriting your WHERE clause to use IN. For example, if you have: SELECT * FROM t JOIN tempTable ON t.someId = tempTable.id You can rewrite that as: SELECT * FROM t WHERE t.someId IN (SELECT * FROM tempTable) MySQL can apply some extra optimizations to the IN clause (e.g. sort the data and search for a match using a binary tree search). Daniel. Manoj Singh wrote:
Hi All, I have a query which returns the large number of ids which i am using in other queries. I am doing this in PHP. Now the first query can return unlimited number of ids which might create problem in PHP. I want to store this ids in MYSQL through temporary table so that i can access that ids in other queries directly. Do you think the approach is right or there is any other good approach? Please suggest. Regards, Manoj


« previous php.db (#46112) next »