Re: [PHP-DB] Is Temporary table right approach

[email protected] (Daniel Carrera)
Newsgroups php.db
Message-ID <[email protected]>
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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.