# Slow SELECT ... LIMIT without WHERE clause on federated table

**URL:** <https://forums.percona.com/t/slow-select-limit-without-where-clause-on-federated-table/605>\
**Category:** Other MySQL® Questions\
**Created:** [January 21, 2008, 4:10pm UTC](https://forums.percona.com/t/slow-select-limit-without-where-clause-on-federated-table/605 "2008-01-21T16:10:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriswest](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@chriswest](https://forums.percona.com/u/chriswest)\
**Post date:** [January 21, 2008, 4:10pm UTC](https://forums.percona.com/t/slow-select-limit-without-where-clause-on-federated-table/605/1 "2008-01-21T16:10:15Z")

</div>

Hi,

I’ve got a problem concerning the federated table engine:

I created a federated table pointing to a reasonable large remote table (about 800.000 rows, row size 211 Bytes, MyISAM).

When sending the following query:

SELECT \* FROM TABLE LIMIT 0,30

the query takes always 9 seconds to complete.

Trying:

SELECT \* FROM TABLE WHERE primaryKey = 1234

is fast as usual (\< 0.001s).

I tried tried the federated table on several db servers, always the same result. Now my question is: Does something happen behind the curtain I don’t know off? Does Mysql fetch the whole index without a WHERE clause? Is some internal sorting required?

Anyway, in my opinion the remote db server serving the data should handle this without any delay, shouldn’t it?

Server running the federated engine:  
Mysql 5.1.22  
Debian Linux 2.6.18-5-amd64

Server serving the data:  
Mysql 4.0.24  
Debian Linux 2.6.8-12-amd64-k8-smp

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![TommyDIY](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@TommyDIY](https://forums.percona.com/u/TommyDIY)\
**Post date:** [February 7, 2008, 3:41am UTC](https://forums.percona.com/t/slow-select-limit-without-where-clause-on-federated-table/605/2 "2008-02-07T03:41:50Z")

</div>

Have you tried to use EXPLAIN

| [B]Quote:[/B] |
| [URL]http://dev.mysql.com/doc/refman/5.0/en/explain.html[/URL] |

or PROFILE

| Quote: |
|   
[URL][http://dev.mysql.com/doc/refman/5.0/en/show-profiles.html[/URL]](http://dev.mysql.com/doc/refman/5.0/en/show-profiles.html%5B/URL%5D)

 |

to see what the query is doing?

---

<div class="post-metadata">

**Author:** ![chriswest](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@chriswest](https://forums.percona.com/u/chriswest)\
**Post date:** [February 7, 2008, 8:50am UTC](https://forums.percona.com/t/slow-select-limit-without-where-clause-on-federated-table/605/3 "2008-02-07T08:50:14Z")

</div>

as expected:

EXPLAIN SELECT \*FROM `table`LIMIT 0 , 30

id select\_type table type possible\_keys key key\_len ref rows Extra1 SIMPLE table ALL NULL NULL NULL NULL 96

Mysql only needs to look at 96 rows to retrieve the result but the query takes 9 seconds to complete. Like I said, if I issue the query ON the server (not using the federated table in another db), the query completes in \< 0.001s.
