OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Select from remote server from stored procedure

From: Harrison Fisk (Harrison.FiskSun.COM)
Date: Wed Dec 09 2009 - 13:06:30 CST


Hello Johan,

On Dec 9, 2009, at 11:22 AM, Johan De Meersman wrote:

> Posted this before, but beware: federated tables do NOT use indices.
> Every
> select is a full table scan, and if you're talking about a logging
> table
> that could become very expensive very fast.

This is not entirely true. If you define an index on the local
federated table, and it makes sense to use it, then a remote WHERE
clause will be passed through and hence use the remote index. Not all
types of index accesses can be passed through such as this, however
for a single row lookup on a primary key, it should be fine.

It is still not as fast as local access, but it's not as bad as always
doing a full table scan remotely.

> On Wed, Dec 9, 2009 at 4:13 PM, Neil Aggarwal
> <neiljammconsulting.com>wrote:
>
>>> Is this possible to do? To make a connection, inside the
>>> stored procedure
>>> to a completely different machine and access the mysql there?
>>
>> The only way I know to access tables from different servers
>> from a single connection is federated tables:
>> http://dev.mysql.com/doc/refman/5.0/en/federated-use.html
>>
>> Once you do that, you are accessing it like a local table.
>>
>> I hope this helps.
>>
>> Neil

Regards,

Harrison
--
Harrison C. Fisk, MySQL Staff Support Engineer
MySQL Sun Microsystems, Inc., http://www.sun.com/mysql/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql